Repository navigation
Conversation
Subagents (`agent.subagents.agent_ids`) were only resolved in the chat UI initialization path. The Responses API (`/v1/responses`) and the OpenAI-compatible API (`/v1/chat/completions`) only ran handoff-edge discovery, so a primary agent invoked through those endpoints never had its subagent spawn targets loaded — the model was unaware of the subagent and could not delegate to it. Extract the subagent-resolution logic from `api/server/services/Endpoints/agents/initialize.js` into a shared `resolveSubagents` helper in `packages/api/src/agents/subagents.ts` and wire it into all three entry points so behavior is identical everywhere. - Add `resolveSubagents` (nested-tree BFS, depth/graph-node limits, dedupe, cycle guard, pure-subagent pruning, per-agent tool-context callback). - Wire it into the Responses and OpenAI-compat controllers using the same `REMOTE_AGENT` sharing boundary as the primary agent. - Refactor the chat path to use the shared helper (no behavior change). - Only fetch `getModelsConfig` when handoff discovery or real subagent loading needs it, keeping the common single-agent request off that path. - Call `resolveSubagents` unconditionally in the remote paths so that when the `subagents` capability is disabled, persisted `subagents` are stripped and `createRun` can't expose self-spawn. - Add unit tests for `resolveSubagents` and mocks for the controller specs. Co-authored-by: Cursor <cursoragent@cursor.com>
|
fixes #14249 |
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ 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". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ 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". |
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Adds a fork-only workflow that builds and pushes librechat-dev images to public ghcr.io without requiring upstream Docker Hub secrets. Co-authored-by: Cursor <cursoragent@cursor.com>
Fail fast with a clear message when repository workflow permissions are read-only instead of read and write. Co-authored-by: Cursor <cursoragent@cursor.com>
Fail fast with a clear message when repository workflow permissions are read-only instead of read and write. Co-authored-by: Cursor <cursoragent@cursor.com>
Job-level packages:write is sufficient even when the repository default workflow token permission is read-only. Co-authored-by: Cursor <cursoragent@cursor.com>
Avoid flaky arm64 npm ci failures under QEMU on GitHub-hosted runners. Co-authored-by: Cursor <cursoragent@cursor.com>
Use repository_owner for registry login, link images to the source repo, retry visibility updates, and avoid failing after a successful push. Co-authored-by: Cursor <cursoragent@cursor.com>
# Conflicts: # .github/workflows/publish-fork-images.yml
# Conflicts: # api/server/services/Endpoints/agents/initialize.js
|
replaced by #15534 |
Summary
Subagents (
agent.subagents.agent_ids) were only resolved in the chat UIinitialization path. The Responses API (
/v1/responses) and theOpenAI-compatible API (
/v1/chat/completions) only ran handoff-edge discovery,so a primary agent invoked through those endpoints never had its subagent spawn
targets loaded — the model was unaware of the subagent and could not delegate to
it.
This PR extracts the subagent-resolution logic into a shared helper and wires it
into all three entry points so behavior is identical everywhere.
Fixes #
Changes
packages/api/src/agents/subagents.ts—resolveSubagents()helpercontaining the logic previously inline in
initialize.js: nested-tree BFS,MAX_SUBAGENT_DEPTH/MAX_SUBAGENT_GRAPH_NODESlimits, id dedupe, self-cycleguard, pure-subagent pruning (kept in
agentToolContextsviaonAgentInitializedforON_TOOL_EXECUTE), and capability-disabled stripping.resolveSubagentsintoresponses.jsandopenai.js, using the sameREMOTE_AGENTsharing boundary and remote permission check as the primaryagent.
initialize.js(chat path) to use the shared helper — no behaviorchange (verified by the existing subagent suite).
subagentAgentConfigsto theInitializedAgenttype and export the newmodule from
packages/api/src/agents/index.ts.getModelsConfigwhen handoff discovery or real subagentloading actually needs it, keeping the common single-agent request off that
(potentially network-bound) path.
resolveSubagentsunconditionally in the remote paths so thatwhen the
subagentscapability is disabled, any persistedsubagentsarestripped and
createRuncan't expose self-spawn.resolveSubagents; add theresolveSubagentsmockto the Responses/OpenAI controller specs; update log-prefix assertions in
initialize.spec.js.Test plan
cd packages/api && npx jest subagents.spec.ts(6 passed)cd api && npx jest server/services/Endpoints/agents/initialize.spec.js -t "subagent"(11 passed / 4 skipped)cd api && npx jest server/controllers/agents/__tests__/responses.unit.spec.js server/controllers/agents/__tests__/openai.spec.js(26 passed)npm run build:data-providerandpackages/apibuild succeedPOST /v1/responsesand confirm the subagent spawn tool is exposed and callable