v0.19.1 · Apache 2.0 · Java 21+
An AI agent is one Java class. Get it wrong and it will not start.
TnsAI checks the class and the builder before the first answer, and tells you which line is wrong.
Break a line
ResearchAssistant.java
IllegalStateException
Action ResearchAssistant.ask names knowledge 'paper', which is not declared; declared: [papers]
Main.java
Refused before the first answerat ResearchAssistant.java:16: IllegalStateException: Action ResearchAssistant.ask names knowledge 'paper', which is not declared; declared: [papers]
Mistakes stop at startup, not in front of a user
Three checks run before the first answer, in this order. Each message is the one you will see.
1 · Role.create(…)
The role is created
The role declares the same source twice
RoleInitializationException
Failed to create role: ResearchAssistant
Caused by IllegalStateException
@RoleSpec on ResearchAssistant declares knowledge 'papers' twice
2 · .build()
The agent is built
No principal or no authority scope
IllegalStateException
AgentBuilder requires accountability wiring: principal=missing, authorityScope=set. Call .principal(...) and .authorityScope(...) on this builder before .build().
Leave out
.authorityScope(…)and it readsauthorityScope=missing.3 · agent.chat(…)
The first call, before the model
An action names a source the role never declared
IllegalStateException
Action ResearchAssistant.ask names knowledge 'paper', which is not declared; declared: [papers]
The first answer
Only an agent that got past all three gets here.
What TnsAI leaves to you
Prompt rules
mustAlways and mustNever are written into the system prompt beside the action on every run. The model is still the one that follows them. For a check at runtime, use a guardrail.
A missing folder
By default, a source that cannot be loaded does not stop the action (onFailure = CONTINUE), and the agent answers without it. Set @Search(onFailure = FAIL) and the first action stops instead:
RetrievalException
FILE knowledge source could not be loaded completely (source 'papers' on ResearchAssistant)
Take only the layers you need
Fourteen runtime modules under one BOM, in four layers. Add a layer as a dependency when you need it.
Runtime
The core every agent runs on, the models it talks to, and the ways to reach it.
The agent runtime
tnsai-core
Roles and actions, checked and run against the model.
Language models
tnsai-llm
One interface over 31 LLM providers, with streaming and cost tracking.
Model Context Protocol
tnsai-mcp
Use tools from any MCP server, or serve your own.
Web server
tnsai-server
Agents over HTTP and WebSocket, with a Dockerfile.
Knowledge
What an agent knows and can do: your documents, its plans and its tools.
Search over documents
tnsai-rag
Vector, keyword and graph search over PDF, Word, Markdown and more.
Database as a source
tnsai-rag-jdbc
A table or a query as a corpus, over plain JDBC.
Planning and memory
tnsai-intelligence
Planners, reasoning and compaction for long conversations.
Built-in tools
tnsai-tools
63 toolkits and 209 tools, from web search to finance.
Teams and quality
Agents working together, kept safe, and scored with numbers.
Agent teams
tnsai-coordination
Eight team shapes, negotiation and voting, in FIPA messages.
Safety and tracing
tnsai-quality
Guardrails, access control and OpenTelemetry tracing.
Scoring and benchmarks
tnsai-evaluation
LLM-judge scores and a regression gate for releases.
Connections
Where the agent meets people, pays for things, and is tested end to end.
Chat apps
tnsai-channels
Telegram, Slack, Discord, WhatsApp, email and the terminal.
Payments
tnsai-payments
Pays for web resources in USDC over x402, within your limits.
Integration tests
tnsai-integration
Tests that run the modules together, and the SCOP bridge.
Your first agent in three steps
Open the quickstartAdd the repository and the BOM
TnsAI is published to its own Maven repository. Import the BOM once and every TnsAI module you add takes the same version.
pom.xmlWrite a role
A role says who the agent is and what it can do. Each @ActionSpec method is one thing it can do; this one runs locally, without a model.
AssistantRole.javaBuild it and run it
AgentBuilder puts the role together with a model client, the principal the agent acts for and what it may do; here, anything for an hour. Start it and the answer comes back as a String.
Main.java
Questions
TnsAI is an open-source Java 21 framework for building production AI agents. It has 14 runtime modules that share one version through one Maven BOM (dev.tnsai:tnsai-bom:0.19.1), published to https://repo.tnsai.dev/maven2. The license is Apache 2.0.
Start with one BOM
dev.tnsai:tnsai-bom:0.19.1