Repository navigation
docs: ADR 0350 — use AgentDef for sessions - #1783
Conversation
Lets a session's main engine run as a named AgentDef specialist (strict tool ceiling, own prompt/model) via a new optional agent_id field on CreateSessionRequest, reusing buildAgentDefEngine as a fourth call site instead of only via Subagent/team delegation. Motivated by issue #1053 (Slack bot identities backed by agent definitions). Co-Authored-By: Claude Sonnet 5 <[email protected]>
Lead with the config-reuse story (one AgentDef, usable as a top-level session or a delegate, no extra wiring) and cut prose length by ~45% without dropping any decision. Also links issue #1784, the open question on session-configurable posture raised during review. Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
I think the core proposal is sound: selecting an 1. Persisted authority attenuationPlease express the tool restriction through the existing authority model, not only catalog construction:
A smaller catalog controls one engine construction; persisted authority prevents later reconstruction or enrollment from restoring excluded capabilities. 2. Omitted
|
Addresses PR #1783 review points 1 and 4 (persisted authority, restart semantics): SetMode/restart-rehydration/MCP-resume don't currently know about agent_id and would rebuild through the generic default catalog, silently widening a restricted session. v1 closes this by failing closed on those paths rather than doing the real persisted-authority fix, which is tracked in #1796. Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
Thanks for this — the core-proposal agreement plus this level of detail is exactly what On #1 (persisted authority) and #4 (restart semantics): you're right, and it's worse I've landed a v1-scoped fix for this rather than the full persisted-authority mechanism Still working through 2, 3, 5, 6, 7, 8, 9 — will follow up on those separately. Fully or partially written by an AI agent. |
- Rename agent_id -> agent_definition_name (point 9): avoids the workload-identity naming collision the ADR already flagged. - Omitted tools: resolves against the same bounded base set a Subagent child gets, never the ordinary root's full catalog (point 2). - PermissionMode conflict is a silent clamp, mirroring Limits, now fixed for the session's whole lifetime via the SetMode rejection (point 3). - Definition hooks wire as the inner HookRunner under the existing modelhook.Runner guardrail decorator - no new mechanism, guardrails always run second and can't be bypassed (point 5). - Named debug_target_session_id exclusivity and no-fs composition rules (point 6). - provider_id/model_id resolved as a pair, not independently, fixing a real mismatch bug; unavailable pinned provider fails closed (point 7). - memory:project binds to the session's own EnvironmentRef, not a deployment default; inert under no-fs (point 8). Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
Follow-up on the rest — all landed in the latest revision. #2 (omitted #3 (fixed permission mode): kept the tighten-only clamp (mirroring #5 (hook composition): turns out this needed zero new mechanism. #6 (other shapes): #7 (provider/model pair): adopted your resolution algorithm as written — it caught a #8 (project memory): for an #9 (naming): renamed #1/#4 already covered in the previous reply — v1 fails closed on restart/ Fully or partially written by an AI agent. |
0350 was taken by "purpose-attributed auxiliary token usage" (#1793), merged to main after this ADR was drafted. Renumbering to the next free slot; also drops the now-stale "draft ADR 0351" label for PR #1730 (0351 itself collided with an unrelated, already-merged Studio ADR, so PR #1730 will need its own renumber before it merges). Co-Authored-By: Claude Sonnet 5 <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ape wrappers Slice A of ADR 0350's implementation (docs/adr/0350-session-scoped-agent-identity.md, still under review in PR #1783 - this branch is exploratory and not yet mergeable). Extracts buildAgentDefEngine's catalog/MCP/skills/hooks/memory resolution into a new resolvedAgentDefCatalog core, so it can be shared between the existing CHILD-shaped construction (buildAgentDefEngine, unchanged behavior) and a new ROOT-shaped construction (buildAgentDefRootEngine) that bottoms out in engineDepsForProvider + buildGuardrailsHooks instead of newChildEngineForProvider - ordinary main-session Deps (real Store/Instructions, AudienceMain policy, guardrails wrapping the def's own hooks) rather than child-shaped Deps. buildAgentDefRootEngine is not yet wired to any session-creation path - that lands in a later slice, alongside the fail-closed rebuild guards it requires. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ape wrappers Slice A of ADR 0350's implementation (docs/adr/0350-session-scoped-agent-identity.md, still under review in PR #1783 - this branch is exploratory and not yet mergeable). Extracts buildAgentDefEngine's catalog/MCP/skills/hooks/memory resolution into a new resolvedAgentDefCatalog core, so it can be shared between the existing CHILD-shaped construction (buildAgentDefEngine, unchanged behavior) and a new ROOT-shaped construction (buildAgentDefRootEngine) that bottoms out in engineDepsForProvider + buildGuardrailsHooks instead of newChildEngineForProvider - ordinary main-session Deps (real Store/Instructions, AudienceMain policy, guardrails wrapping the def's own hooks) rather than child-shaped Deps. buildAgentDefRootEngine is not yet wired to any session-creation path - that lands in a later slice, alongside the fail-closed rebuild guards it requires. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Durable behavioral and interface contract for ADR 0353 (Session-scoped agent identity, merged as #1783). Architectural work classification; 3 scenarios, 25 acceptance criteria, 7 open human decisions (keeps the plan draft). Drafted via /to-acceptance-plan, reviewed by one devils-advocate pass and two specialist spot-checks (secure-code-reviewer, software-architect), all folded in: - devils-advocate: fixed a contradiction between AC2.5's original claim and the ADR's own text vs. actual code (memory:project placement), surfaced a hidden Limits zero-value decision, removed a task-shaped AC, added missing no-fs composition coverage. - software-architect: confirmed the buildAgentDefEngine split and the new AgentDefSessionEngineFactory's shape, flagged a 15-argument positional-prefix duplication risk and a provider/model resolver delegation opportunity for the eventual implementation. - secure-code-reviewer: found a CRITICAL, code-verified guardrail bypass (a definition hook's mutated payload is never re-inspected by the guardrail checker today) and a HIGH-severity mistargeted fail-closed guard (the real choke point is needsRehydration()/engineAndEnvironmentFor, not rehydrateSession, and RetryFailedRun/CompactSession/resumeFromAwaiting share the same exposure) - both now explicit ACs and human decisions. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Durable behavioral and interface contract for ADR 0353 (Session-scoped agent identity, merged as #1783). Architectural work classification; 3 scenarios, 25 acceptance criteria, 7 open human decisions (keeps the plan draft). Drafted via /to-acceptance-plan, reviewed by one devils-advocate pass and two specialist spot-checks (secure-code-reviewer, software-architect), all folded in: - devils-advocate: fixed a contradiction between AC2.5's original claim and the ADR's own text vs. actual code (memory:project placement), surfaced a hidden Limits zero-value decision, removed a task-shaped AC, added missing no-fs composition coverage. - software-architect: confirmed the buildAgentDefEngine split and the new AgentDefSessionEngineFactory's shape, flagged a 15-argument positional-prefix duplication risk and a provider/model resolver delegation opportunity for the eventual implementation. - secure-code-reviewer: found a CRITICAL, code-verified guardrail bypass (a definition hook's mutated payload is never re-inspected by the guardrail checker today) and a HIGH-severity mistargeted fail-closed guard (the real choke point is needsRehydration()/engineAndEnvironmentFor, not rehydrateSession, and RetryFailedRun/CompactSession/resumeFromAwaiting share the same exposure) - both now explicit ACs and human decisions. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Summary
Proposed ADR: let a session's main engine run as a named
AgentDefspecialist — restricted tool allowlist, own system prompt, own model — selected at session-creation time via a new optionalagent_idfield onCreateSessionRequest. Today anAgentDefis only ever reachable as a child (Subagent(agent=...)or a team member); this reuses the existingbuildAgentDefEnginecomposition step (already shared by 3 call sites) as a fourth call site, rather than a new mechanism.Motivated by issue #1053 ("Slack bot: multiple @-mentionable identities backed by mecatl agent definitions") — a Slack bot on
@stacklok/mecatl-sdkneeds sessions bound to specific tool-restricted identities on mecak8s.Key decisions (see the ADR for full rationale):
mcp_servers/debug_mcp_serverson the request are rejected whenagent_idis settools:says soPermissionModeare tighten-only against the def's configprovider_id/model_idfollow the existing empty-means-unset precedence (request > def > default)Design-doc only — no implementation in this PR.
Test plan
task docs:check— 0 broken links, 0 broken anchors, 0 orphans, 0 unreachable🤖 Generated with Claude Code