TnsAI
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

AspectLLMLAM (TnsAI)
OutputText generationAction execution
CapabilityLanguage understandingReal-world interaction
ArchitectureTransformerBDI + Tools + Memory
StateStatelessPersistent beliefs
LearningPre-trainedRuntime adaptation

BDI to LAM Terminology Mapping

TnsAI uses BDI (Belief-Desire-Intention) architecture internally, which maps directly to LAM concepts:

BDI TermLAM TermTnsAI ClassPurpose
BeliefPerceptionBeliefWorld state understanding
DesireGoal/IntentDesireWhat to achieve
IntentionPlanIntentionHow to achieve it
ActionAct@Action methodsExecution

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?

  1. Beyond Chat: Not just**italic conversation, but action execution
  2. Enterprise Ready: Java-native, type-safe, production-ready
  3. Extensible: 57+ tools, custom actions, MCP support
  4. Observable: OpenTelemetry integration for monitoring
  5. 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

On this page