ποΈ fix: Scope Handoff Agent Context Docs - #13167
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes multi-agent attachment scoping for the Agents endpoint by separating shared run attachments (safe to share across agents in the same run) from agent-scoped context documents (per-agent permanent context), and ensuring the scoped document text is injected into each agentβs dynamic instructions so token budgeting/pruning accounts for it.
Changes:
- Split
primeResourcesoutput intorequestAttachments(shared run files) vsagentContextAttachments(per-agent context-doc files), while keeping legacyattachmentsfor compatibility. - Plumb
requestAttachments+ anagentContextAttachmentsByAgentIdmap throughinitializeClientβAgentClient, and inject per-agent scoped doc text viaadditional_instructions. - Add regression tests covering direct context-doc chats, handoff scoping isolation, and shared request attachment behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/api/src/agents/resources.ts | Enhances resource priming to return both shared request attachments and agent-scoped context attachments. |
| packages/api/src/agents/resources.test.ts | Updates/extends unit tests validating the new attachment split behavior. |
| packages/api/src/agents/initialize.ts | Adopts new primeResources fields, adds compatibility behavior, and exposes both attachment groups on InitializedAgent. |
| packages/api/src/agents/tests/initialize.test.ts | Adds coverage ensuring initializeAgent preserves separation of request vs context attachments. |
| api/server/services/Endpoints/agents/initialize.js | Collects per-agent context attachments and passes shared vs scoped attachment data into AgentClient. |
| api/server/services/Endpoints/agents/initialize.spec.js | Adds regression assertions for request attachment sharing and per-agent context isolation. |
| api/server/controllers/agents/client.js | Injects per-agent scoped context-doc text into each agentβs run context (without leaking across agents). |
| api/server/controllers/agents/client.test.js | Adds tests ensuring shared request context is applied to all agents while scoped docs remain isolated per agent. |
π‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
GitNexus: π deployedThe |
|
@codex review |
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 13bbd7f930
βΉοΈ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
GitNexus: π deployedThe |
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! βΉοΈ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with π. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
GitNexus: π deployedThe |
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! βΉοΈ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with π. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
* fix: Scope agent context docs to handoff agents * fix: Deduplicate scoped request context * refactor: Extract agent attachment helpers
* fix: Scope agent context docs to handoff agents * fix: Deduplicate scoped request context * refactor: Extract agent attachment helpers
* fix: Scope agent context docs to handoff agents * fix: Deduplicate scoped request context * refactor: Extract agent attachment helpers
Summary
I fixed agent context document scoping so shared run files remain available to every agent while each primary, handoff, or direct agent only receives its own permanent context documents.
Change Type
Testing
npm run build:data-providernpm run build:data-schemasnpm run build:apicd packages/api && npx jest src/agents/resources.test.ts src/agents/__tests__/initialize.test.ts --runInBandcd api && npx jest server/controllers/agents/client.test.js server/services/Endpoints/agents/initialize.spec.js --runInBandTest Configuration:
Checklist