Skip to content
tnsaiDocs
GitHub

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

AspectLLMLAM (TnsAI)
OutputText generationTyped action execution
CapabilityLanguage understandingTools, HTTP, MCP, local methods
ArchitectureTransformerLLM + @ActionSpec + memory
StateStatelessConversation memory (MemoryStore)
LearningPre-trainedRuntime 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?

  1. Beyond chat: not just conversation, but typed action execution
  2. Enterprise-ready: Java-native, type-safe
  3. Extensible: shipped POJO toolkits, custom POJOs, MCP
  4. Observable: OpenTelemetry
  5. 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