Repository navigation
Description
Original Request
From the round-2 review discussion on PR 575:
you're saying that
dreb -p -e [extension path]doesn't allow subagents to inherit the extension? feels like a gap worth noting but maybe I agree not a merge blocker here since it'll require a lot more buildout to fix
On a parent started with --api-key:
not sure if there is any issue passing the key forward to children... seems okay to me?
Fold it into the followup issue for
-e.
Summary
Each subagent is a separate dreb process started with a fixed argument list. Two things the parent gets only from its own command line never reach that process: extensions loaded with -e/--extension, and an API key supplied with --api-key. Subagents therefore lack the parent's session-only extensions, and they cannot authenticate with a key given only on the command line. PR 575 makes unconfigured subagents inherit the parent's model, so this now affects every default subagent call when the parent's model depends on either.
Current Behavior
- Spawn arguments:
spawnSubagent(packages/coding-agent/src/core/tools/subagent.ts, theargsbuilder) passes only mode, session, model/provider, thinking, tools, system prompt, agent type, parent session, and task. It never passes-e,--no-extensions, or--api-key. - Extensions:
- Subagents load only the extensions they discover themselves (
~/.dreb/agent/extensions/,.dreb/extensions/, settings). An extension loaded with-eis missing from every subagent, along with its tools, hooks, and providers. - If that extension registered the provider the parent is running on, the parent's pre-spawn check still passes, because the parent's registry has the provider. The subagent then exits with
Unknown provider "<name>". - The reverse also happens:
--no-extensionson the parent does not stop subagents from loading discovered extensions.
- Subagents load only the extensions they discover themselves (
- API key:
--api-keyis stored only in the parent's memory, as a runtime override for the selected model's provider (main.ts,AuthStorage.setRuntimeApiKey).AuthStorage.hasAuth()counts that override, so the parent's pre-spawn auth check passes.- The subagent never receives the key. Unless the key is also in
auth.jsonor a provider environment variable, the subagent fails withNo API key found for <provider>. This happens in both interactive and print modes.
- Already true before PR 575: single-model mode (issue 517) always inherited the parent's model. PR 575 makes inheritance the default route.
Proposed Behavior
- Subagents of a session started with
-e <path>load the same session-only extensions.--no-extensionscarries over the same way. - Subagents can authenticate with a key the parent received through
--api-key. - Forwarding must not expose the key more widely than it is in the parent:
- Not on the subagent's command line, which other local users can read through
ps. - Not in a standard provider environment variable such as
OPENAI_API_KEY. The bash tool passes its whole environment to every shell command (packages/coding-agent/src/utils/shell.ts), so the subagent's commands could read a key that the parent's own commands cannot.
- Not on the subagent's command line, which other local users can read through
Acceptance Criteria
- A subagent spawned from a session started with
dreb -e <path>has that extension's tools, hooks, and providers. This includes a parent running on a model from a provider that extension registers. - A subagent spawned from a session started with
--no-extensionsloads no discovered extensions. - If the parent was started with
--api-keyand has no other credentials for that provider, a subagent on the inherited model authenticates with that key. - The forwarded key does not appear in the subagent's command line, and the subagent's tool subprocesses cannot read it from their environment.
Open Questions
- Should every
-eextension load in subagents, or should extensions be able to opt out (for example, UI-only extensions)? - Should the other session-only resource flags (
--skill,--prompt-template,--no-skills,--no-prompt-templates) follow the same rule?
Technical Notes
- One possible key transport: a dreb-specific environment variable that the subagent reads and deletes from
process.envat startup, before any tool runs. - The parent's pre-spawn inheritance check (
resolveParentModelinsubagent.ts) uses the parent's registry and auth state. As a result it passes in exactly the cases above where the subagent later fails. - Found during the round-2 review of PR 575: assessment.
Activity