You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The positions AgentLoom as the recommended runtime for users who want resilience, observability, and budget enforcement. AgentAnvil must expose AgentLoomBackend as an LLMBackend implementation, but only when agentloom is installed. The portability invariant (#022) requires that pip install agentanvil with no extras still imports and runs — so AgentLoomBackend must fail to import gracefully.
Three concrete requirements:
1. Optional dependency.agentanvil[agentloom] pins agentloom[contracts,observability]>=0.5.0. Without the extra, AgentLoomBackend raises a clear error on instantiation, not on import.
2. Trace-parsing via agentloom.contracts. Use SpanAttr, MetricName enums from AgentLoom 0.5.0 to parse emitted OTel spans into AgentAnvil's canonical Trace (from #5). If agentloom.contracts does not ship Pydantic trace models (decision point D1), use raw span dict parsing.
3. Budget enforcement passthrough. Users set max_cost_usd on the backend; AgentLoom's budget tracker enforces it and AgentAnvil reports partial results if the budget is breached.
test_agentloom_backend_contract_passes_abc_suite (with extra installed)
Notes
Decision point D1: if agentloom.contracts ships Pydantic trace models in 0.5.0, the adapter consumes them directly; otherwise we parse span dicts. Either way, SpanAttr enum names are the stable surface.
Decision point D7 (the planning notes, closed 2026-04-22): agentloom.contracts ships with explicit .stable / .experimental split. The backend consumes Message, ToolDef, LLMResponse, Usage, RunContext from agentloom.contracts.stable (semver-guaranteed); trace span names and metric enums come from agentloom.contracts.experimental (may break in minor releases with programmatic warning). This mitigates D1 risk — even if Pydantic trace models shift, the adapter's stable imports remain bound only to the six core types in .stable.
Do not import AgentLoom at module top-level — always inside try/except ImportError.
Description
The positions AgentLoom as the recommended runtime for users who want resilience, observability, and budget enforcement. AgentAnvil must expose
AgentLoomBackendas anLLMBackendimplementation, but only whenagentloomis installed. The portability invariant (#022) requires thatpip install agentanvilwith no extras still imports and runs — soAgentLoomBackendmust fail to import gracefully.Three concrete requirements:
1. Optional dependency.
agentanvil[agentloom]pinsagentloom[contracts,observability]>=0.5.0. Without the extra,AgentLoomBackendraises a clear error on instantiation, not on import.2. Trace-parsing via
agentloom.contracts. UseSpanAttr,MetricNameenums from AgentLoom 0.5.0 to parse emitted OTel spans into AgentAnvil's canonicalTrace(from #5). Ifagentloom.contractsdoes not ship Pydantic trace models (decision point D1), use raw span dict parsing.3. Budget enforcement passthrough. Users set
max_cost_usdon the backend; AgentLoom's budget tracker enforces it and AgentAnvil reports partial results if the budget is breached.Proposal
1. Module skeleton:
2. Trace adapter:
3. Tests under optional extras:
agentloom: import ofagentanvil.backends.agentloommodule succeeds, instantiation raisesImportError.agentanvil[agentloom]: full integration tests run.Scope
src/agentanvil/backends/agentloom.py— new.src/agentanvil/backends/_agentloom_adapter.py— new.pyproject.toml— confirmagentloom = ["agentloom[contracts,observability]>=0.5.0"]extra is declared.tests/backends/test_agentloom_import_without_extra.py— portability invariant.tests/backends/test_agentloom_with_extra.py— integration (only run when extra installed)..github/workflows/ci.yml— addagentloom-integrationjob with optional extra.Regression tests
test_agentloom_backend_without_extra_raises_importerror_on_instantiationtest_agentloom_backend_module_imports_without_extra(portability invariant)test_span_to_llm_response_parses_gen_ai_attrstest_span_to_llm_response_handles_missing_reasoning_tokenstest_agentloom_backend_contract_passes_abc_suite(with extra installed)Notes
agentloom.contractsships Pydantic trace models in 0.5.0, the adapter consumes them directly; otherwise we parse span dicts. Either way,SpanAttrenum names are the stable surface.agentloom.contractsships with explicit.stable/.experimentalsplit. The backend consumesMessage,ToolDef,LLMResponse,Usage,RunContextfromagentloom.contracts.stable(semver-guaranteed); trace span names and metric enums come fromagentloom.contracts.experimental(may break in minor releases with programmatic warning). This mitigates D1 risk — even if Pydantic trace models shift, the adapter's stable imports remain bound only to the six core types in.stable.try/except ImportError.AgentLoomBackendraising gracefully).