Agents and prompts¶
English translation pending
Full content currently exists only in Russian. Use the language selector at the top of the page → Русский. The summary below covers the essentials.
AI is a scalpel, not a sledgehammer (VISION). An agent in Axon is a workflow function: a workflow whose config shape is
agent_config(or a reference to a reusableAgentDefinitionviaagent_ref). It runs through the sameWorkflowRunnerand passes the same policy / budget / approval gates as any other step.
1. What it is and why¶
PromptVersion(tableapp.prompt_versions, id prefixpver_<ulid>) — versioned prompt template with placeholders. PROMPT-SCOPE.AgentDefinition(tableapp.agent_definitions, id prefixagdef_<ulid>) — versioned AgentSpec with pinnedprompt_version_id(notkey:latest). AGENTSPEC + AGENTS-FINISH.- Both are append-only versioned for replay determinism. Runtime/replay only accepts pinned ids (no
key:latestat runtime). - All LLM calls go through LiteLLM proxy via Pydantic AI / Instructor. Direct provider SDKs are forbidden in business logic (CLAUDE.md).
- An agent is not a separate service, not a separate execution process, and not a license to bypass policy/approval gates.
2. Roles and access¶
| Action | Permission | owner | admin | manager | operator | reviewer | read_only | system |
|---|---|---|---|---|---|---|---|---|
| Publish/archive/set-active prompt version | prompt:manage |
✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ |
| Publish/archive AgentDefinition | agent_definition:manage |
✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ |
| Read prompts / agents | read |
✅ | ✅ | ✅ | ✅ | ✅ | ✅ | — |
Manager does not have prompt:manage / agent_definition:manage: prompt content is part of the code surface (engineers author, owner/admin publish). system is granted for the seed-on-create-project flow. All mutations go through CommandEnvelope (sync_apply) — backdoor SQL is forbidden.
3. Where in Console¶
- Prompts (
/{project_id}/promptsor/admin/prompts): list / detail / history / publish-new-version / archive / set-active. - Agents (
/{project_id}/agentsor/admin/agents): list / detail / history / publish-new-version / archive.
Console reads only via query API over read.prompt_versions / read.agent_definitions projections — never app.* directly.
4. Concepts¶
- Scope —
instance(project_id IS NULL) orproject. Project-scope entry shadows an instance-scope one with the same key. Foroutput_schema_refshadowing is explicit only — silent fallback to instance is forbidden (output_schema_ref_instance_scope_not_allowed). - Pinning — authoring uses
key:*refs; materialization boundary (publish_definition,create_workflow,edit_workflow) replaces them with pinnedagdef_*/pver_*. Runtime/replay accepts pinned only. - AgentSpec tool exposure rule (ARCHITECTURE-V6 §11) — direct agent tools are restricted to
side_effect_class="none"∩ projectenabled_tools∩ executor profileallowed_tools.internal/external_*actions are workflow steps (tool_call/external_write) with policy gate, not direct agent tools. - Output schema XOR —
AxonAgentSpecmust declare exactly one ofoutput_fields/output_schema_jsonschema/output_schema_python.output_schema_pythonis forbidden fororigin='user'specs. - UPGRADE_CHAIN (adaptive routing) — cheap-by-default, escalate on validator failure: haiku → sonnet → opus (
core/ai/model_router.py). Each call (including failed) recordsselected_model,complexity_score,routing_modeinbudget_ledger. InvariantI-DOMAIN-AGENTSPEC-ROUTING-UPGRADE-CHAIN(AGENTS-FINISH Bundle B). - Validator retry-with-feedback —
pydantic_outputphase retries with feedback up toretries(0–5);post_acceptancephase only logs. InvariantI-DOMAIN-AGENTSPEC-VALIDATOR-RETRY-FEEDBACK(Bundle C). - No code-owned fallback seeds — built-ins seed only via migrations 040–041 (system actor);
built_in_specs.pywas removed (Bundle A invariantI-DOMAIN-AGENTSPEC-NO-CODE-FALLBACK-SEEDS).AgentSpecResolverraisesLookupErroron miss;AgentPromptResolverno longer acceptsfallback:*.
5. Flows¶
- Create a prompt in a project — Prompts → + New prompt → fill content + placeholders →
publish_prompt_version. Pre-accept secret scan rejects token-like strings. The prior active version with the same(scope, project, key)is auto-archived. - Publish AgentDefinition — write
AxonAgentSpecin code / Console form →publish_agent_definition. Handler validates XOR output schema, scope contract, input builder contract, deps_overrides safety, resolves prompt to pinnedpver_*, insertsagdef_<ulid>, archives the prior active. - Use AgentDefinition in a workflow —
Step(step_type="model_call", config={"agent_ref": "key:email_classifier", ...}).axon pushmaterializeskey:*→agent_definition:id:agdef_*. Runtime accepts only pinned form. - Use
output_schema_reffor a model_call —output_schema_ref="agent_definition:key:<key>". Materialized into pinned form; silent fallback to instance scope rejected. - Rotate a prompt — Publish new version → old auto-archived. Existing AgentDefinitions keep pointing at the pinned old
pver_*; to use the new version, publish a new AgentDefinition. - Grant agent access to a new direct tool — tool must be
side_effect_class="none", in projectenabled_tools, inexecutor_profile.allowed_tools; then addtool_keysin a newpublish_agent_definition.
6. Options reference¶
See the Russian manual §6 for the full field reference of PromptVersionSpec (MAX_PROMPT_CONTENT_LENGTH=32_000, MAX_PLACEHOLDERS_PER_PROMPT=32, etc.) and AxonAgentSpec (output schema XOR, retries: 0..5, tool_keys unique, scope contract, deps_overrides safety). Command surface: publish_prompt_version / archive_prompt_version / set_prompt_version_active (target prompt_version, prompt:manage); publish_agent_definition / archive_agent_definition (target agent_definition, agent_definition:manage); all sync_apply.
7. Lifecycle and operations¶
- Per-project seed.
create_projecthandler callsensure_project_seed_agent_definitions()in the same transaction;PROJECT_AGENT_SEEDScovers triage/planner/reviewer/conversation.monitoris seeded instance-scope. - Versioning. Append-only. Exactly one active per
(scope, project_id, key); the rest archived. Archived rows survive for compliance and replay pin safety. - Pin-protection on
archive_prompt_version: rejected if the prompt version is pinned by any active AgentDefinition. Publish a new AgentDefinition first. - Reactivation.
set_prompt_version_active(pver_X)allowed; no pin-protection (replay pins keep working through id). - Observability. Langfuse trace per LLM call (
prompt_version_id,agent_definition_id,selected_model,complexity_score, validator outcomes);budget_ledgerrow per call.
8. Troubleshooting¶
| Symptom | Cause | Fix |
|---|---|---|
publish_prompt_version → 422 «secret-like string» |
pre-accept secret scan tripped | Remove the literal token / API key / credential URL |
archive_prompt_version → 409 prompt_pinned_by_active_agents |
Some active AgentDefinition pins this prompt version | Publish a new AgentDefinition without that pin, then retry |
publish_agent_definition → 422 «exactly one of output_fields/jsonschema/python required» |
XOR violated | Pick one |
publish_agent_definition → 422 «output_schema_python forbidden for user-origin» |
user-origin pointing at a Python class | Use output_fields or output_schema_jsonschema |
publish_definition → output_schema_ref_instance_scope_not_allowed |
Project workflow refers to AgentDefinition by key:*, no project-scope row exists |
Publish AgentDefinition in this project, or use explicit agent_definition:id:agdef_* |
| Agent ignores a tool | Tool not side_effect_class="none", or not in project enabled_tools, or not in executor_profile.allowed_tools |
Fix the failing gate |
| Operator wants an audited read tool | Requires a separate public contract (no implicit rule) | Use tool_call step with policy gate, or open a new backlog item |
| Adaptive routing keeps escalating to opus | Validator keeps failing or complexity estimated very high | Check Langfuse; tighten prompt/schema/validator; or force routing_mode='fixed' |
9. Constraints and invariants¶
- No code-owned fallback seeds (
I-DOMAIN-AGENTSPEC-NO-CODE-FALLBACK-SEEDS). - Upgrade chain order haiku → sonnet → opus (
I-DOMAIN-AGENTSPEC-ROUTING-UPGRADE-CHAIN). - Validator retry-with-feedback semantics by execution phase (
I-DOMAIN-AGENTSPEC-VALIDATOR-RETRY-FEEDBACK). - Pinning is mandatory at runtime / replay for
agent_refandoutput_schema_ref. - AgentSpec tool exposure rule — direct agent tools are
noneonly; project allowlist; executor profile cap. - Output schema Python class — system/code origin only.
- Secrets never appear in prompts (pre-accept scan).
- Scope contract — project ⇔ project_id required; instance ⇔ project_id IS NULL; no cross-project leak.
- No silent shadowing for
output_schema_refto instance scope. - AI is not mandatory at any level (VISION); workflows without agents are first-class.
10. Related manuals and canon¶
- Workflows.md, Connectors-Credentials.md, Approvals.md, Budgets-And-Cost.md, Security-And-Audit.md.
- Canon:
ARCHITECTURE-V6.md§10/§11/Appendix A;WORKFLOW-ARCHITECTURE.md§4;CONCEPT-AGENTSPEC.md,CONCEPT-PROMPT-SCOPE.md;core/models/{agent_specs,prompt_specs}.py; alembic 039–042;tests/invariant_registry.yaml.