feat(decisioning): forward ctx.agent to tasks_get accounts.resolve#1323
Merged
Conversation
`tasks_get` now resolves the calling BuyerAgent (when an `agentRegistry` is configured) and threads it to `platform.accounts.resolve` as `ctx.agent`. Closes the asymmetry left by PR #1315 + #1321: the custom- tool path historically bypassed registry resolution because it sits outside the dispatcher's main handler-dispatch flow, leaving adopters' resolve impls to see `ctx.agent: undefined` on tasks_get calls but populated on every other tool. **Status enforcement is deliberately NOT replicated.** A buyer agent suspended after kicking off an HITL task must still be able to poll for terminal state — refusing the poll would strand work with no visibility. The dispatcher's main path enforces status at request entry; the polling path does not. Sellers who want hard cutoff implement that policy inside their own `accounts.resolve` (read `ctx.agent.status`, throw `AdcpError`). Tests pin both contracts (agent IS forwarded; suspended/blocked agents CAN still poll) so a future refactor that tightens status enforcement onto the polling path fails loudly rather than silently breaking running workflows. Registry failures during a poll fall through to `agent: undefined` rather than breaking the poll — same defensive shape as the dispatcher. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Per security-reviewer defense-in-depth note on PR #1323. The swallow stays (poll must survive transient IDP outages), but a log entry makes upstream IDP failures visible to operators — without it, buyers seeing REFERENCE_NOT_FOUND for valid tasks because adopters' resolvers return null without `ctx.agent` would be invisible in adopter logs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why this needs fixing
The contract docstrings landed on `upsert?` / `reportUsage?` / `getAccountFinancials?` in the prior two PRs say "prefer `ctx.agent` for principal-keyed gates." That guidance was a half-truth as long as `tasks_get` skipped registry resolution: an adopter who wrote their resolver to key on `ctx.agent` would see it undefined on every `tasks_get` call and have to special-case the polling path.
Why status enforcement stays off the polling path
The dispatcher comment at `create-adcp-server.ts:2796-2802` makes the policy explicit: status checks (suspended/blocked → 403) deliberately skip on `tasks_get` polls and background webhooks because refusing the poll would strand in-flight work with no visibility. This PR pins that policy in tests rather than relying on its current emergent behavior, so future tightening fails loudly.
What's NOT in scope
Compatibility
No behavior change for adopters that don't read `ctx.agent` from inside their resolver.
Test plan
🤖 Generated with Claude Code