Skip to content

feat: Let self subagents take host arguments through a resolver - #711

Merged
danny-avila merged 1 commit into
mainfrom
danny-avila/self-subagent-host-args
Nov 18, 2026
Merged

danny-avila merged 1 commit into
mainfrom
danny-avila/self-subagent-host-args

Conversation

@danny-avila

Copy link
Copy Markdown
Collaborator

Why

LibreChat lets a parent agent pass per-call host arguments (workspace, machine) to a subagent so the child runs its code tools in a chosen checkout on a paired machine. The SDK merges every subagent type's declared hostArgs into the one subagent tool schema, so once any named child declares workspace, the model sees workspace as a parameter for every type, including self.

self could never accept it. In the last 14 days LibreChat's Lia agent got this tool result 15 times, each time while launching a background copy of herself in the librechat checkout:

{"status":"rejected","tool":"subagent","message":"Error: Subagent \"self\" does not accept \"workspace\". Omit it for this subagent type."}

LibreChat cannot fix this on its side. In 4.2.9, normalization rejects every shape that would let a self config receive host arguments:

Self config shape 4.2.9
self + hostArgs throws "declares hostArgs, which only a lazy resolveAgentInputs config without eager agentInputs can receive"
self + hostArgs + sanitized agentInputs throws (same)
self + resolveAgentInputs + hostArgs throws "cannot combine self with resolveAgentInputs"

Because normalization runs while the parent graph builds its subagent tool, adding hostArgs to the self config would break subagent setup for the whole run, not just one call.

Change

A self: true config may now declare hostArgs together with resolveAgentInputs and a non-empty configId:

{
  self: true,
  type: 'self',
  name, description,
  agentInputs,                 // optional sanitized copy, as before
  configId: 'self@<revision>',
  hostArgs: { workspace: { description, enum: [...] } },
  resolveAgentInputs,          // called only for calls that pass host args
}
  • Call without host args: unchanged. The child runs on the provided agentInputs, otherwise the parent's own inputs. The resolver is not called.
  • Call with host args: SubagentExecutor.resolveExecutionConfig calls resolveAgentInputs with context.hostArgs, as it does for lazy configs. Before this change it skipped the resolver whenever agentInputs was set; it now still skips it in every case except this one.
  • Self handling on both paths: the resolved config keeps self: true, so prepareChildInputs still drops graphTools and compactionSemanticIndex.
  • Validation, binding and resume: unchanged and shared with lazy configs. Values are validated against the declared specs before any execution opens, with the same model-visible messages. hostArgsDigest is recorded and checked the same way, a resume with matching arguments goes back through the resolver with the persisted execution id, and a resume with changed arguments is rejected with "Subagent invocation changed for this execution." configId is the definition identity for every call to that config.
  • Feature probe: SELF_SUBAGENT_HOST_ARGS_SUPPORTED (true) is exported from the package root, so hosts can attach hostArgs to self only on SDKs that accept it.

Argument names are not special-cased; host arguments stay declared specs.

Compatibility

  • Every other config shape validates as before. Without hostArgs, self + resolveAgentInputs still throws "cannot combine self with resolveAgentInputs". hostArgs on eager configs, with or without a resolver, and on graph configs still throws the existing errors. A lazy config keeps its existing messages.
  • New errors only for the newly accepted shape: self + hostArgs without a resolver, or without a configId.
  • A host that starts sending a configId on its self config changes that config's definition identity. Paused self executions recorded under the old identity will report "configuration changed" on resume, as with any configId change.
  • No version bump or release in this PR.

Tests

  • src/tools/subagent/__tests__/hostArgs.test.ts, new self subagent host arguments block:
    • normalization of the new shape (parent inputs and a provided copy);
    • the tool schema advertising the self config's workspace;
    • rejection of the self shape without a resolver or configId, and of self + resolver without hostArgs;
    • eager configs still rejected;
    • a call with host args reaching the resolver, with self handling applied to the resolved inputs;
    • calls without host args keeping today's inputs with the resolver never called;
    • invalid and undeclared values giving the existing messages;
    • a resolver refusal mapped to the fixed host-argument message;
    • resume with matching and with changed host args;
    • a background self execution forwarding host args.
  • src/specs/subagent-host-args.test.ts: a full Run where the parent's self config declares workspace. The routed call reaches the resolver; the call without the argument does not.
  • Pre-existing tests for the other rejected combinations pass unchanged.

The pre-commit hook runs Prettier over every staged file, so SubagentExecutor.ts also carries formatting-only changes to lines this PR does not otherwise touch.

A self config may now declare hostArgs together with resolveAgentInputs
and a configId. Calls that pass host arguments resolve through the
resolver with context.hostArgs; calls that pass none keep the provided
agentInputs or the parent inputs. The resolved config stays self, so
graphTools and compactionSemanticIndex are still dropped, and digest,
binding and resume behave as for lazy configs.

SELF_SUBAGENT_HOST_ARGS_SUPPORTED lets hosts feature-detect the shape.
Every other config shape validates as before.
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T12:39:58.357668Z 6a51393 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 6a51393d06

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

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 6a51393d06

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

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review — final review pass for this PR (head 6a51393).

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 6a51393d06

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

@danny-avila
danny-avila merged commit ba767e3 into main Nov 18, 2026
13 checks passed
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