This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
CLAUDE.md is a symlink to this file. Always edit AGENTS.md directly; never modify CLAUDE.md.
- README.md: high-level usage and supported frameworks.
- CONTRIBUTING.md: canonical dev setup, test matrix, and contribution workflow.
- pyproject.toml and .pre-commit-config.yaml: formatting/lint/typecheck configuration.
- docs/: Astro/Starlight docs site (configured by docs/astro.config.mjs).
src/any_agent/: Core library.AnyAgentis the main entry point;AgentConfigandAgentFrameworkdefine config.src/any_agent/frameworks/: One module per supported framework (agno, google, langchain, llama_index, openai, smolagents, tinyagent). Each implementsAnyAgent's abstract methods via lazy imports to keep optional dependencies isolated.src/any_agent/callbacks/: Callback system with per-framework wrappers (wrappers/) and span generation (span_generation/). Base class isCallbackinbase.py.src/any_agent/tools/: Built-in tools (web browsing, user interaction, final output) plus MCP client integration (mcp/), A2A tools, and Composio integration.src/any_agent/tracing/: OpenTelemetry-based tracing.AgentTrace/AgentSpanare the primary types.src/any_agent/evaluation/: LLM judge and agent judge evaluators.src/any_agent/serving/: A2A protocol and MCP server implementations for serving agents.src/any_agent/vendor/: Vendored adapters (langchain_any_llm, llama_index_utils).tests/:unit/,integration/,snapshots/, plus shared fixtures intests/conftest.py.
This repo uses uv for local dev (Python 3.11+). For the full, up-to-date command set, follow CONTRIBUTING.md.
- Create env + install dev deps:
uv venv && source .venv/bin/activate && uv sync --dev --extra all - Run all checks (preferred):
uv run pre-commit run --all-files --verbose - Unit tests:
uv run pytest -v tests/unit - Single test file:
uv run pytest -v tests/unit/frameworks/test_tinyagent.py - Single test:
uv run pytest -v tests/unit/frameworks/test_tinyagent.py::test_function_name - Integration tests (require API keys):
uv run pytest -v tests/integration - Docs preview:
cd docs && npm run dev
- Python indentation: 4 spaces; formatting/linting via
ruffandpre-commit. Line length is not explicitly capped (E501 is ignored). - Type hints: required;
mypyruns in strict mode for library code (seepyproject.toml). The mypy pre-commit hook runs viauv run mypy. - Framework code lives under
src/any_agent/frameworks/<framework>.py(keep framework-specific behavior isolated there). - Lazy imports are used extensively for optional framework dependencies (e.g.,
smolagents,langchain,openai-agents). The ruff rulePLC0415is disabled to allow this. - Prefer direct attribute access (e.g.,
obj.field) overgetattr(obj, "field")when the field is typed. - Please add code comments if you find them helpful to accomplish your objective. However, please remove any comments you added that describe obvious behavior before finishing your task.
- Never use emdashes or -- in any comments or descriptions.
- Framework:
pytest(+pytest-asyncio,pytest-xdist). Async mode isautowith session-scoped event loop. - Add/adjust tests with every change (happy path + error cases). Integration tests should
pytest.skip(...)when credentials/services aren't available. - New code should target ~85%+ coverage. Write tests for every branch in new code, including error/raise paths and edge cases, so that patch coverage passes in CI.
- Do not use class-based test grouping (
class TestFoo:). All tests should be standalone functions. - Do not add decorative section-separator comments (e.g.,
# -----------banners). - Place imports at the top of test files unless the import is for an optional dependency that may not be installed (e.g., framework-specific SDKs). In that case, inline imports inside the test function are acceptable.
- Snapshot tests live in
tests/snapshots/usingsyrupy.
AnyAgent.create()/create_async()is the main factory. It resolvesAgentFrameworkto a concrete subclass via_get_agent_type_by_framework(), instantiates it, then calls_load_agent().- Every framework subclass must implement
_load_agent(),_run_async(),update_output_type_async(), and theframeworkproperty. - Tools are normalized to framework-native types by
_wrap_tools()intools/wrappers.py. MCP tools (stdio, SSE, streamable HTTP) are connected viaMCPClient. - The callback system hooks into each framework differently via
callbacks/wrappers/<framework>.py. Wrappers monkey-patch or register framework-native hooks to fire the unifiedCallbackmethods. AgentTracecollectsAgentSpanobjects (OpenTelemetry spans). Traces include token/cost info, duration, and can be serialized to JSON.AgentCancelis a special exception base class for intentional cancellation from callbacks. It propagates through framework error wrapping via_unwrap_agent_cancel().- The
any-llm-sdkpackage (from the siblingany-llmrepo) is a core dependency providing the unified LLM interface used by all framework integrations.
- Commits follow Conventional Commits:
feat(scope): ...,fix: ...,chore(deps): ...,tests: .... - PRs should include a clear description, linked issues, and completed checklist.
- Never commit secrets. Use environment variables or a local
.env(gitignored) for provider API keys.