Skip to main content

tai42-agents

License: Apache 2.0

The reference agents package for the TAI ecosystem — an opt-in, manifest-loaded collection of generic agents built on the deepagents/LangGraph runtime.

Every agent here registers through the tai42_app handle from tai42_contract.app and is loaded by the host from the manifest (agents[].module). Its only tai-* dependencies are tai42-contract (the Agent ABC, the StreamEvent taxonomy, and the tai42_app handle it registers through) and tai42-kit (settings machinery and the llm factories model access goes through). It never imports the skeleton — tai42-agents is contract-facing.

The TAI ecosystem

TAI is an open-source runtime for MCP tools, agents, and workflows. An agent is a capability the runtime hosts and exposes as a tool; the six here are the platform's ready-made, batteries-included set. This repo is their per-agent reference doc home; the documentation site covers using them and the platform-level story:

Install

Requires Python 3.13+. Install from PyPI into the environment that runs the server:

uv add tai42-agents

Or from source — clone this repo and add it as an editable dependency; the tai42-* dependencies resolve in-tree from the workspace.

git clone https://github.com/tai42ai/tai42   # next to your app checkout
cd /path/to/your/app
uv add --editable ../tai42/plugins/agents

The agent runtime (deepagents, langgraph, langchain-core, langchain, pydantic, pydantic-settings, opentelemetry-api, wcmatch) is a base dependency — agents are this package's purpose, so there is no runtime extra to opt into. Model-provider SDKs are never direct dependencies here: model access goes through tai42-kit's llm factories, configured per deployment.

Registering an agent

An agent is a class subclassing the contract Agent ABC, registered under a name with the @tai42_app.agents.agent(name) decorator. Registration fires when the module imports (import-to-register); the host imports the module because the manifest names it:

agents:
  - title: my-agents
    module: tai42_agents.<module>
    # include: [<agent name>]   # optional — omit to expose all agents in the module
from pydantic import BaseModel
from tai42_contract.agent import Agent
from tai42_contract.app import tai42_app


class EchoInput(BaseModel):
    user_message: str = ""


@tai42_app.agents.agent("echo")
class EchoAgent(Agent):
    tool_name = "echo"
    tool_description = "Echoes the user message back."
    ToolInput = EchoInput  # a JSON-able pydantic model of the tool params

    async def run(self, *, user_message: str = "", **kwargs):
        return user_message

Registration gives each agent two faces, both derived from the one class:

  • an in-process astream method (API / SSE facing) that yields the contract's StreamEvent taxonomy (ReasoningStep, ToolCallStep/ToolResultStep, MessageDelta, MessageFinal, RunUsage, StructuredFinal, InterruptFinal);
  • an auto-generated JSON run tool (LLM / MCP / programmatic callers facing) whose signature is the agent's ToolInput model.

Agents

The package ships six agents, each in its own module so a manifest can load exactly the ones a deployment wants:

  • tools_agent (tai42_agents.tools_agent) — the plain/advanced LangGraph tools agent. Uniform tool inputs: tool_names (client tools resolved through the app registry), live tools, and presets (a base tool bound to fixed kwargs; a sub-flow is base_tool="flow" with fixed_kwargs={"flow_graph": ...}).
  • langchain_deep_agent (tai42_agents.langchain_deep_agent) — a deepagents-harness agent: planning, a per-thread scratch filesystem, skills (served live from the template provider or supplied inline), one level of nested subagents, and human-in-the-loop interrupts with resume via a LangGraph Command. Both faces fail loudly when a requested response_format produces no structured output: the invoke face raises on drain, and the stream face raises after the stream drains (a pending interrupt takes precedence over the raise).
  • retrieval_tools_agent (tai42_agents.retrieval_tools_agent) — a tools agent that does not bind every tool to the model up front: it embeds each tool's description into a vector store and exposes a retrieve_tools semantic-search tool, binding matches on demand until the model emits a terminal {"status": ...} object. Useful when the tool set is large.
  • voting_agent (tai42_agents.voting_agent) — runs N voter LLMs in parallel over one prompt, then a judge LLM decides by majority vote (breaking ties with its own reasoning). Returns a VotingOutput; only the judge streams.
  • refine_agent (tai42_agents.refine_agent) — an Evaluator↔Critic loop: the evaluator drafts, the critic reviews, and they alternate until the critic emits the approval token or the iteration budget is exhausted (a loud RuntimeError, never an unapproved draft). Only the final approved pass streams.
  • vqa_agent (tai42_agents.vqa_agent) — visual question answering: a single multimodal completion over an image_url and a query. No tools, no graph.

Expose kwargs-carrying agents to trusted callers only. base_url/api_key in llm_kwargs/embedding_kwargs legitimately route to a caller-chosen model/embedding endpoint; expose any agent or tool carrying these kwargs only to trusted callers — an injected parent agent could redirect the model/embedding call to a hostile endpoint and leak the key/context.

Wire the ones you want in the manifest — one agents: entry per module, each with a title; add include: to expose a subset of a module's agents:

agents:
  - title: tools-agent
    module: tai42_agents.tools_agent
  - title: deep-agent
    module: tai42_agents.langchain_deep_agent
  - title: retrieval-tools-agent
    module: tai42_agents.retrieval_tools_agent
  - title: voting-agent
    module: tai42_agents.voting_agent
  - title: refine-agent
    module: tai42_agents.refine_agent
  - title: vqa-agent
    module: tai42_agents.vqa_agent

Import rule

The shipped tai42_agents package imports tai42-contract, tai42-kit, and the agent runtime (deepagents / langgraph / langchain-core / langchain / pydantic / opentelemetry / wcmatch) — the declared dependencies and their resolved dependency closure — plus the standard library. It never imports tai42-skeleton, which sits a layer above, and never reaches for a package that is not a dependency of the shipped wheel. The rule is enforced twice: ruff (flake8-tidy-imports bans) fails lint on a skeleton import, and an import-graph test asserts every root in the module graph is on the allowlist — once by importing every shipped module in a fresh subprocess and inspecting sys.modules, and once by parsing every shipped source file, so an import nested in a function body, a class body, or a TYPE_CHECKING block is caught too.

Development

uv venv --python 3.13
uv pip install --no-sources --editable ".[dev]"
uv run --no-sync ruff check .
uv run --no-sync ruff format --check .
uv run --no-sync pyright
uv run --no-sync pytest --cov --cov-report=term-missing

Dependency install is plain. The deepagents/LangGraph stack (deepagents, langgraph, langchain-core, langchain, pydantic, opentelemetry-api) resolves as ordinary wheels from the index — no vendor directory and no PYTHONPATH bridge.

License

Apache-2.0. See LICENSE and NOTICE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tai42_agents-4.0.1.tar.gz (152.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tai42_agents-4.0.1-py3-none-any.whl (178.7 kB view details)

Uploaded Python 3

File details

Details for the file tai42_agents-4.0.1.tar.gz.

File metadata

  • Download URL: tai42_agents-4.0.1.tar.gz
  • Upload date:
  • Size: 152.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for tai42_agents-4.0.1.tar.gz
Algorithm Hash digest
SHA256 c95b7313dea8b371201d5ecf16d6840395768d7d3b95930f05015a9e558e5fa2
MD5 71cf9eebb37ff381461b621b109480aa
BLAKE2b-256 2bda0721ea877e58e113a7cd30c1266de832ea986ce7481682da9403205c3ef0

See more details on using hashes here.

File details

Details for the file tai42_agents-4.0.1-py3-none-any.whl.

File metadata

  • Download URL: tai42_agents-4.0.1-py3-none-any.whl
  • Upload date:
  • Size: 178.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for tai42_agents-4.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6c3e8d4247fd11cdcfc1fd187a613b7140ecc71c7944fa144514048833b43b5f
MD5 94bcdeae62ca92c7b7cdb8f4a46e99cb
BLAKE2b-256 376cd787761ceec40ca9f05ded8fc28b1fb7ffb84de62835308111bae098490f

See more details on using hashes here.

Release history Release notifications | RSS feed

5.5.0

2 files

5.4.1

2 files

5.4.0

2 files

5.3.0

2 files

5.2.1

2 files

5.2.0

2 files

5.1.1

2 files

5.1.0

2 files

5.0.0

2 files

This release

4.0.1 This release

2 files

4.0.0

2 files

3.0.2

2 files

3.0.1

2 files

3.0.0

2 files

2.3.0

2 files

2.2.0

2 files

2.1.1

2 files

2.1.0

2 files

2.0.1

2 files

2.0.0

2 files

1.0.0

2 files

0.9.0

2 files

0.8.0

2 files

0.7.0

2 files

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

0.3.7

2 files

0.3.6

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page