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.
Add or Modify a Session Workflow🔗
- Keep frontend-neutral request/result models and programmatic operations in
crates/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
crates/ag-store/src/domain modules. Userepository.rsfor repository bundle composition andconnection.rsfor pool wiring; keep Agentty'scrates/agentty/src/infra/db.rslimited to database-location and clock composition. - Keep git operations behind
GitClientincrates/ag-git/src/client.rs. - Preserve the session-branch invariant: one evolving commit per session branch, with the first file-changing turn creating it and later file-changing turns updating it by amending
HEAD. - Update docs when lifecycle/status behavior changes:
docs/site/content/docs/usage/workflow.md.
Add a New Agent Backend or Model🔗
- Declare model ids, descriptions, provider order, speed support, and known context budgets together in the catalog in
crates/ag-session/src/agent.rs. Keep provider defaults and retired-id mappings explicit; removing a public enum variant is a Rust API change even when saved ids remain compatible. - For a new backend, add behavior in
crates/ag-agent/src/agent/and register it incrates/ag-agent/src/agent/provider.rs. Existing backends consume catalog capabilities instead of maintaining their own model lists. - Keep transport selection, parsing, streaming, and provider setup in the provider registry; application workflows continue through worker clients.
- Update
docs/site/content/docs/agents/backends.mdwith backend/model documentation. - Keep explicit expectations in model, default, and retirement tests. Use the
ag-sessiontest-utilsfixtures for unrelated workflows so model replacements do not require editing each test.
Add a Built-in ag-router Model🔗
- Add the model's wire capabilities and reasoning mapping in
crates/ag-router/src/provider.rs; keep provider HTTP and response decoding inag-router. - Add local HTTP tests for the schema format, image and tool capabilities, reasoning fields, and error mapping. Keep harness tool execution and permissions in
ag-harness. - Expose the built-in model through
ag-harnessconfiguration only if the harness supports its capabilities; Agentty product integration still follows the worker and runtime boundary. - To offer it in Agentty Harness sessions, add it to the
Harnessentries of theag-sessionmodel catalog and declare itsModelProfileincrates/ag-agent/src/agent/model_profile.rs; anag-agenttest rejects ids the harness catalog does not know.
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. - Inject
&dyn RunClientinto the smallest workflow helper that needs deterministic coverage and test it withMockRunClient. - Keep provider routing, protocol repair, usage aggregation, and runtime cleanup in
crates/ag-agent/src/agent/submission.rs.
Add a Keybinding or Mode Interaction🔗
- For basic text editing, add or update the semantic command in
crates/agentty/src/domain/input.rs, then map terminal keys once incrates/agentty/src/runtime/mode/input_key.rs. - Let prompt, question, branch-publish, and settings input modes intercept only their context-specific actions before falling back to the shared input command mapping.
- For other interactions, update the handler in
crates/agentty/src/runtime/mode/, or incrates/agentty/src/runtime/key_handler.rswhen the interaction is a cross-mode overlay dispatch. - If a new mode/state is needed, extend
crates/agentty/src/presentation/app_mode.rs. - If help content changes, update
crates/agentty/src/presentation/help_action.rsas needed. - Update
docs/site/content/docs/usage/keybindings.md.
Add or Change Database Schema🔗
- Add a new migration file in
crates/ag-store/migrations/(NNN_description.sql). - Never modify existing migration files.
- Keep query changes in the matching
crates/ag-store/src/*.rsdomain module instead of expanding Agentty's composition facade. - Ensure any status/model behavior changes are reflected in docs pages affected by user-facing behavior.
Add a New UI Page or Component🔗
- Add the page in
crates/agentty/src/ui/page/or component incrates/agentty/src/ui/component/. - Wire the page into
crates/agentty/src/ui/router.rs. - If a new
AppModeis needed, extend the shared presentation contract implemented incrates/agentty/src/presentation/app_mode.rsand exported throughcrates/agentty/src/presentation.rs, then add a key handler incrates/agentty/src/runtime/mode/.
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. Keep durable scope instructions aligned.
- Reuse cached derived data on render hot paths; measurement and painting must agree.
- Keep the runtime key-types table current when execution contracts change, and the boundary reference current when external traits change.
- Run the required gates in root
AGENTS.md.
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. Submit session turns throughSessionRunClientand utilities throughRunClient. - Import execution contracts from
ag-contractsand selections fromag-session. Constructag-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. Background work must capture purpose and session/project ownership with ag-worker::scoped_client. Nested utilities retain parent cancellation and run directly under worker supervision, without enqueueing behind the session command awaiting them.
See Execution for the execution contract.