Skip to content
tnsaijava agent framework

TnsAI as a Language-Action Model (LAM)

Industry writing calls this a Large Action Model: an LLM that does not stop at text, but selects and runs typed actions. In TnsAI that mapping is @ActionSpec methods plus registered tools. The chat loop is LLM + tools, not a BDI interpreter — see Roles.

Belief, Desire, and Intention remain as model types. They are not seeded on AgentBuilder and Agent has no getBeliefs() / getDesires() / getIntentions(). Optional BDI planning goes through the CognitiveModel SPI — see SPI Reference.

+-------------------------------------------------------------+
|                 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 vocabulary (model types, not Agent overrides)

Application-owned lists, if you keep them yourself:

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(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

Shipped POJO toolkits (BuiltInTool) plus HTTP actions via nested @WebService — not a flat @ActionSpec.endpoint.

@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.getMemoryStore() is protected (override the factory). The public handle is getAgentMemoryStore(). MemoryStore records conversation turns with addMessage — there is no store(key, value) API.

agent.getAgentMemoryStore().addMessage("user", "prefers concise answers");

3. Multi-Agent Coordination

There is no A2AClient type. In-process topologies live under Multi-agent. Google A2A protocol support is tracked separately and is not shipped.

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 — circuit breakers, retry policies, crash recovery

Getting Started

// AgentBuilder has no .belief(...) (TNS-541)
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