Skip to content

🤖 perf: reuse agent definitions within stream requests - #3954

Open
yanncabral wants to merge 1 commit into
coder:mainfrom
yanncabral:yann/reuse-agent-discovery
Open

🤖 perf: reuse agent definitions within stream requests#3954
yanncabral wants to merge 1 commit into
coder:mainfrom
yanncabral:yann/reuse-agent-discovery

Conversation

@yanncabral

Copy link
Copy Markdown

Summary

Reuses parsed agent-definition packages within a single stream request so agent resolution, inherited body/frontmatter construction, and available-subagent discovery do not repeatedly read the same winning definition file.

Implementation

  • Adds a request-owned AgentDefinitionRequestCache keyed by the concrete runtime and normalized source path, with winning lookups recorded only after successful parsing.
  • Preserves same-scope root precedence and invalid-candidate fallback across .xum, .mux, host-global, and plugin sources.
  • Carries plugin attribution through cached descriptor construction.
  • Wires reuse through agent resolution, inheritance, stream-context body/frontmatter resolution, and available-subagent discovery.
  • Adds end-to-end regression coverage for project → global → built-in inheritance, shadowing, invalid same-scope candidates, disabled filtering, desktop gating, inherited runnable state, and tool policy. The selected definition is read four times without the seam and once with request-scoped reuse.

Validation

  • bun test src/node/services/agentResolution.test.ts src/node/services/agentDefinitions/agentDefinitionsService.test.ts src/node/services/streamContextBuilder.test.ts src/node/services/aiService.test.ts — 144 passed
  • Prettier write/check for all touched files
  • git diff --check
  • Fresh read-only review: no Critical or Important findings

make build-main, targeted ESLint, and bun run tsgo --noEmit -p tsconfig.main.json were attempted repeatedly but the local processes were killed with exit 137/SIGKILL in the constrained workspace.

Risks

This touches agent precedence and inheritance plumbing. The cache is intentionally request-scoped and only stores successfully parsed winners by concrete source identity; existing fallback, disablement, desktop capability, and policy behavior remains covered by the integration test and existing service suites.


Generated with xum • Model: openai:gpt-5.6-sol • Thinking: medium • Cost: $unknown

@yanncabral

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 07fd5bbee8

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 07fd5bbee8

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant