feat(agents): per-call forge-token override in AgentDispatchPort.dispatch() #521

Closed
opened 2026-04-28 09:25:16 +00:00 by claude-desktop · 0 comments
Collaborator

User story

As a caller dispatching against a repo whose token has just rotated, I want to pass the token explicitly in AgentDispatchRequest, so that dispatch does not rely on a possibly-stale config.tokens[forge] lookup.

Why

Audit (2026-04-28): agent-runner.ts:666–672 resolves the forge token from the loaded config snapshot at dispatch time. Token rotation requires a config reload; in-flight dispatches between rotation and reload pick up a stale token and fail forge calls.

Acceptance criteria

  • AgentDispatchRequest.forgeToken?: string overrides the registry default when provided
  • DefaultAgentDispatch passes the override to both McpRegistryPort.serversFor() and the per-task ForgePort factory
  • When the override is present, the registry default is never read (verified by test fake)
  • Default behaviour unchanged when override absent

Tests

  • Unit: dispatch with override → MCP spec carries override, forge adapter constructed with override
  • Unit: dispatch without override → falls back to registry default

Out of scope

  • Token rotation orchestration / hot-reload mechanism
  • Audit logging of which token a dispatch used (could be a follow-up)

References

  • apps/server/src/infrastructure/agents/agent-runner.ts:666–672
  • AgentDispatchPort interface (preceding issue)
## User story As a caller dispatching against a repo whose token has just rotated, I want to pass the token explicitly in `AgentDispatchRequest`, so that dispatch does not rely on a possibly-stale `config.tokens[forge]` lookup. ## Why Audit (2026-04-28): `agent-runner.ts:666–672` resolves the forge token from the loaded config snapshot at dispatch time. Token rotation requires a config reload; in-flight dispatches between rotation and reload pick up a stale token and fail forge calls. ## Acceptance criteria - [ ] `AgentDispatchRequest.forgeToken?: string` overrides the registry default when provided - [ ] `DefaultAgentDispatch` passes the override to both `McpRegistryPort.serversFor()` and the per-task `ForgePort` factory - [ ] When the override is present, the registry default is never read (verified by test fake) - [ ] Default behaviour unchanged when override absent ### Tests - [ ] Unit: dispatch with override → MCP spec carries override, forge adapter constructed with override - [ ] Unit: dispatch without override → falls back to registry default ## Out of scope - Token rotation orchestration / hot-reload mechanism - Audit logging of which token a dispatch used (could be a follow-up) ## References - `apps/server/src/infrastructure/agents/agent-runner.ts:666–672` - AgentDispatchPort interface (preceding issue)
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/claude-hooks#521
No description provided.