Architecture
TnsAI as a Large Action Model (LAM) Framework
Overview
TnsAI is a Large Action Model (LAM) Framework for Java - enabling agents that perceive, plan, and act in the world.
+-------------------------------------------------------------+
| LARGE ACTION MODEL |
+--------------+--------------+--------------+----------------+
| PERCEPTION | GOAL | PLAN | ACT |
| (Belief) | (Desire) | (Intention) | (Action) |
+--------------+--------------+--------------+----------------+
| BDI ARCHITECTURE |
+-------------------------------------------------------------+LAM vs LLM
| Aspect | LLM | LAM (TnsAI) |
|---|---|---|
| Output | Text generation | Action execution |
| Capability | Language understanding | Real-world interaction |
| Architecture | Transformer | BDI + Tools + Memory |
| State | Stateless | Persistent beliefs |
| Learning | Pre-trained | Runtime adaptation |
BDI to LAM Terminology Mapping
TnsAI uses BDI (Belief-Desire-Intention) architecture internally, which maps directly to LAM concepts:
| BDI Term | LAM Term | TnsAI Class | Purpose |
|---|---|---|---|
| Belief | Perception | Belief | World state understanding |
| Desire | Goal/Intent | Desire | What to achieve |
| Intention | Plan | Intention | How to achieve it |
| Action | Act | @Action methods | Execution |
LAM Architecture in TnsAI
1. Perception Layer (Beliefs)
// Beliefs represent the agent's understanding of the world
protected List<Belief> getBeliefs() {
return List.of(
new Belief("Current date: " + LocalDate.now()),
new Belief("User prefers concise responses"),
new Belief("Available tools: web search, calculator")
);
}2. Goal Layer (Desires)
// Desires represent what the agent wants to achieve
protected List<Desire> getDesires() {
return List.of(
Desire.goal("Provide accurate information"),
Desire.goal("Complete tasks efficiently"),
Desire.goal("Maintain user privacy")
);
}3. Planning Layer (Intentions)
// Intentions represent the agent's current plans
protected List<Intention> getIntentions() {
return List.of(
new Intention("Research topic", "Use search tools"),
new Intention("Summarize findings", "Extract key points")
);
}4. Action Layer (Execution)
// Actions are executable methods
@Action(description = "Search the web for information")
public ActionResult searchWeb(String query, ActionResult result) {
// Execution logic
return result;
}LAM Patterns in TnsAI
Hierarchical LAM (HLM)
Multi-level planning and execution:
HierarchicalAgentOrchestrator orchestrator = HierarchicalAgentOrchestrator.builder()
.strategicAgent(plannerAgent) // Goal decomposition
.tacticalAgent(coordinatorAgent) // Sub-task planning
.operationalAgents(workerAgents) // Action execution
.build();
HierarchicalResult result = orchestrator.execute("Build a web scraper");Large Reasoning Model (LRM)
Advanced reasoning capabilities:
// Self-consistency reasoning
SelfConsistencyExecutor executor = SelfConsistencyExecutor.builder()
.llm(client)
.numPaths(5)
.aggregation(Aggregation.MAJORITY_VOTE)
.build();
// Tree of Thoughts exploration
TreeOfThoughtsExecutor tot = TreeOfThoughtsExecutor.builder()
.llm(client)
.pruning(PruningStrategy.BEAM_SEARCH)
.maxDepth(5)
.build();LAM Capabilities
1. Tool Use
// 57+ built-in tools for real-world interaction
@Action(type = ActionType.WEB_SERVICE)
public ActionResult fetchWeather(String city, ActionResult result) {
return result;
}2. Memory Persistence
// Long-term memory for context retention
agent.getMemoryStore().store("user_preference", "concise");3. Multi-Agent Coordination
// Agent-to-Agent communication
A2AClient client = new A2AClient("https://other-agent.com/a2a");
TaskResponse response = client.sendTask("Research quantum computing");4. Iterative Refinement
// Ralph pattern for output quality
RefinementLoop loop = RefinementLoop.builder()
.task("Convert Python to TypeScript")
.completionCriteria(criteria)
.maxIterations(10)
.build();Why LAM Framework?
- Beyond Chat: Not just**italic conversation, but action execution
- Enterprise Ready: Java-native, type-safe, production-ready
- Extensible: 57+ tools, custom actions, MCP support
- Observable: OpenTelemetry integration for monitoring
- Resilient: Circuit breakers, retry policies, crash recovery
Getting Started
// Create a LAM agent
Agent agent = AgentBuilder.create()
.llm(new GeminiClient("gemini-2.0-flash"))
.role(new ResearcherRole())
.belief(new Belief("accuracy", "Always verify sources"))
.tool(new WebSearchTool())
.build();
// Execute actions
String result = agent.chat("Research latest AI developments");References
- 8 LLM Architectures Explained - LAM positioning
- TnsAI GitHub - Source code
- BDI Architecture - Theoretical foundation
TnsAI Docs
Previous Page
Agents
An `Agent` is the top-level orchestrator in TnsAI. It owns an LLM client, one or more roles, a memory store, and an event system. Agents handle the full chat loop: receiving a message, consulting their roles for available actions, calling the LLM, executing tool calls, and returning a response.