TnsAI as a Language-Action Model (LAM)
A Language-Action Model is an LLM that selects and runs typed actions instead of only returning text. In TnsAI those actions are @ActionSpec methods and registered tools, and the agent's chat loop sends messages to the LLM and runs the tools it calls.
Belief, Desire and Intention are model types that you can keep yourself. AgentBuilder does not set them up. For BDI planning, see CognitiveModel.
+-------------------------------------------------------------+
| LANGUAGE-ACTION MODEL |
+--------------+--------------+--------------+----------------+
| PERCEPTION | GOAL | PLAN | ACT |
| (Belief) | (Desire) | (Intention) | (Action) |
+--------------+--------------+--------------+----------------+
| LLM + TOOLS + TYPED @ActionSpec |
+-------------------------------------------------------------+LAM vs LLM
| Aspect | LLM | LAM (TnsAI) |
|---|---|---|
| Output | Text generation | Typed action execution |
| Capability | Language understanding | Tools, HTTP, MCP, local methods |
| Architecture | Transformer | LLM + @ActionSpec + memory |
| State | Stateless | Conversation memory (MemoryStore) |
| Learning | Pre-trained | Runtime adaptation via tools and memory |
BDI model types
Keep these lists in your application if you use them:
List<Belief> perceptions = List.of(
new Belief("Current date: " + LocalDate.now()),
new Belief("User prefers concise responses"),
new Belief("Available tools: web search, calculator")
);
List<Desire> goals = List.of(
new Desire("Provide accurate information", Priority.CRITICAL, "User trust depends on accuracy"),
new Desire("Complete tasks efficiently", Priority.HIGH, ""),
new Desire("Maintain user privacy", Priority.HIGH, "")
);
List<Intention> plans = List.of(
new Intention("Research topic", "Use search tools"),
new Intention("Summarize findings", "Extract key points")
);Actions are discovered @ActionSpec methods on a Role:
@ActionSpec(type = ActionType.LOCAL, description = "Search the web for information")
public ActionResult searchWeb(String query, ActionResult result) {
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)
SelfConsistencyExecutor executor = SelfConsistencyExecutor.builder()
.llm(client)
.numPaths(5)
.aggregation(Aggregation.MAJORITY_VOTE)
.build();
TreeOfThoughtsExecutor tot = TreeOfThoughtsExecutor.builder()
.llm(client)
.evaluator(BranchEvaluator.llm(evalClient))
.pruning(PruningStrategy.BEAM_SEARCH)
.maxDepth(5)
.build();LAM Capabilities
1. Tool Use
Agents use the shipped toolkits (BuiltInTool) and HTTP actions, which declare their endpoint in a nested @WebService.
@ActionSpec(
type = ActionType.WEB_SERVICE,
webService = @WebService(endpoint = "https://api.weather.com/v1/current")
)
public ActionResult fetchWeather(String city, ActionResult result) {
return result;
}2. Memory Persistence
agent.getAgentMemoryStore() returns the agent's MemoryStore, which records conversation turns with addMessage.
agent.getAgentMemoryStore().addMessage("user", "prefers concise answers");3. Multi-Agent Coordination
Agents in the same process work together through the topologies in Multi-agent.
4. Iterative Refinement
RefinementLoop loop = RefinementLoop.builder()
.task("Convert Python to TypeScript")
.completionCriteria(criteria)
.maxIterations(10)
.build();Why LAM Framework?
- Beyond chat: not just conversation, but typed action execution
- Enterprise-ready: Java-native, type-safe
- Extensible: shipped POJO toolkits, custom POJOs, MCP
- Observable: OpenTelemetry
- Resilient: retry policies and crash recovery
Getting Started
Agent agent = AgentBuilder.create()
.llm(new GeminiClient("gemini-2.0-flash"))
.role(new ResearcherRole())
.builtInTools(BuiltInTool.WEB_SEARCH_TOOLS)
.principal(principal)
.liabilitySink(sink)
.authorityScope(scope)
.build();
String result = agent.chat("Research latest AI developments");References
- Roles
- SPI: CognitiveModel
- 8 LLM Architectures Explained: industry LAM positioning
- TnsAI GitHub: source
- BDI Architecture: theoretical vocabulary