Change Recipes
Concrete change paths for common contribution scenarios, plus a contributor checklist.
Use these recipes to route changes through the correct modules without crossing layer boundaries. Module routers and doc comments identify the exact files.
Add or Modify a Session Workflow🔗
- Keep frontend-neutral request/result models and programmatic operations in
ag-session. - Update Agentty orchestration in
crates/agentty/src/app/session/and adapt it throughcrates/agentty/src/app/session_api.rs. - Route background-callable operations through the bounded actor in
crates/agentty/src/app/session_runtime.rs; do not shareAppbehind an async mutex. - Keep persistence in
ag-storedomain modules and Git operations behindGitClient. - Preserve the session-branch invariant: an unpublished branch holds one evolving commit, created by the first file-changing turn and amended by later ones; a published branch gains one commit per file-changing turn instead.
- Update
docs/site/content/docs/usage/workflow.mdwhen lifecycle or status behavior changes.
Add an Agent Definition🔗
Add a repository definition under .agents/agents/<id>/agent.md, or a bundled definition under crates/ag-session/src/agents/. Both use the same parser. Keep host workflow contracts separate from definition identity and preserve task snapshots when changing admission or continuation.
Define a Generic Execution Graph🔗
Follow the execution graph contracts and their design reasons. Keep model-authored proposals in ag-protocol, pure graph shapes and resolution in ag-session, durable snapshots, results, and atomic admission in ag-store, and dispatch in the ag-worker GraphExecutor. Inject worker adapters through GraphNodeRunner, place nodes in their Envs through GraphEnvResolver, and share GraphResources Env leases with other host work. Test structural rules without storage or workers, storage invariants with SQLite, and dispatch through the public API.
Add a New Agent Backend or Model🔗
- Declare model IDs, descriptions, provider order, speed support, and known context budgets together in the
ag-sessionmodel catalog. Keep provider defaults and retired-ID mappings explicit; removing a public enum variant is a Rust API change. - For a new backend, add behavior in
crates/ag-agent/src/agent/and register it in the provider registry. Backends consume catalog capabilities instead of keeping their own model lists. - Keep transport selection, parsing, streaming, and provider setup in
ag-agent; application workflows continue through worker clients. - Update
docs/site/content/docs/agents/backends.md.
Add a Built-in ag-router Model🔗
- Add the model's wire capabilities and reasoning mapping to its
ProviderSpecpreset incrates/ag-router/src/preset.rs. A provider that needs no new wire behavior needs no code: hosts describe it with aProviderSpec. - Add local HTTP tests for schema format, capabilities, reasoning fields, and error mapping, and a golden request to the protocol's conformance suite under
crates/ag-router/tests/. - Expose it through
ag-harnessconfiguration only if the harness supports its capabilities. - To offer it under
ag-harnessin Agentty's/model, add it to theHarnessentries of theag-sessionmodel catalog.ag-agentregisters it from itsag-harnessModelSpec; declare aModelProfileinag-agentonly when that specification has none.
Add or Change a Utility Agent Prompt🔗
- Submit an owned
OneShotRequestthrough the workerRunClient; do not select a CLI, app-server, backend, or protocol-repair helper from application orchestration. - Choose the request kind by what the task reads.
AgentRequestKind::TextGenerationanswers from the prompt alone, such as a title or a one-word decision, and is sent without tools, repository instruction files, or workspace policy. UseAgentRequestKind::UtilityPromptwhen the task inspects the worktree or follows repository guidance. - Inject
&dyn RunClientinto the smallest workflow helper that needs deterministic coverage and test it withMockRunClient. - Background work captures purpose and ownership with
ag-worker::scoped_client; nested utilities keep parent cancellation and never queue behind the session command awaiting them. - Keep provider routing, protocol repair, usage aggregation, and runtime cleanup in
ag-agent.
Add a Keybinding or Mode Interaction🔗
- For text editing, add the semantic command in
crates/agentty/src/domain/input.rsand map terminal keys once incrates/agentty/src/runtime/mode/input_key.rs. - Let context-specific input modes intercept only their own actions before falling back to the shared mapping.
- Change prompt composer state in the pure reducer of
crates/agentty/src/runtime/mode/prompt.rsand request app work as an effect, so unit tests need noApp. - Update other handlers in
crates/agentty/src/runtime/mode/, or the cross-mode overlay dispatch incrates/agentty/src/runtime/key_handler.rs. - Extend
crates/agentty/src/presentation/app_mode.rsfor a new mode andcrates/agentty/src/presentation/help_action.rsfor help content. - Update
docs/site/content/docs/usage/keybindings.md.
Add or Change Database Schema🔗
- Add a new migration in
crates/ag-store/migrations/(NNN_description.sql); never modify existing migrations. - Keep query changes in the matching
ag-storedomain module. - Update user-facing docs affected by status or model behavior changes.
Change What a Platform's Sync Receives🔗
- Build every value a Sync request sends in
crates/agentty/src/domain/platform_sync.rsand check it again incrates/agentty/src/infra/platform.rsbefore sending. - Keep answer text in session transient output only, never in a transcript or prompt. The one exception is the held task's milestone, which reaches session turns only through
TurnRequest::task_milestone, fenced and escaped bycrates/ag-agent/src/agent/prompt.rs. - Update the Sync section of
SECURITY.mdanddocs/site/content/docs/usage/platform.mdwith what is sent and when.
Add a New UI Page or Component🔗
- Add the page in
crates/agentty/src/ui/page/or component incrates/agentty/src/ui/component/, and wire pages intocrates/agentty/src/ui/router.rs. - For a new
AppMode, extendcrates/agentty/src/presentation/app_mode.rsand add a key handler incrates/agentty/src/runtime/mode/.
Change run execution🔗
- Update shared lifecycle contracts in
ag-contractsand provider behavior inag-agent. - Keep mailboxes, session runtime ownership, scheduling, cancellation, and recovery in
ag-worker; implement product-specific question, Git, forge, and UI policy in the host adapter. - Construct
ag-agentadapters only insideag-runtime; applications configure workers. - Extend headless contract tests and the affected Agentty workflow tests. Changes to operation persistence also need
ag-storeadapter tests.
Adding model-assisted work🔗
Use the utility prompt recipe and the Execution contract.
Contributor Checklist for Architecture-Safe Changes🔗
- Follow Module Map for layer ownership and Testability Boundaries for external-system injection.
- Update the relevant user guide for visible changes and the canonical architecture page when its contracts change, including the runtime key-types table and the boundary table.
- Reuse cached derived data on render hot paths; measurement and painting must agree.
- Run the required gates in root
AGENTS.md.