Skip to content

fix(delegation): normalize child runtime tuple#25386

Open
dorukardahan wants to merge 3 commits into
NousResearch:mainfrom
dorukardahan:fix/delegate-runtime-tuple-normalization
Open

fix(delegation): normalize child runtime tuple#25386
dorukardahan wants to merge 3 commits into
NousResearch:mainfrom
dorukardahan:fix/delegate-runtime-tuple-normalization

Conversation

@dorukardahan

Copy link
Copy Markdown
Contributor

Summary

  • Normalize the child agent runtime tuple before constructing AIAgent.
  • Preserve explicit delegation.base_url and ACP transport overrides.
  • Add regression tests for stale inherited base_url and explicit endpoint preservation.

Why

Current main already passes target_model during delegation provider resolution via #19623. PR #25369 also avoids inheriting stale api_mode when the provider changes. There is still one unsafe state: a child can have the intended provider/model but keep a stale inherited base_url, api_key, or api_mode from the parent. That can send a request to the wrong API surface.

This patch asks the existing runtime provider resolver for the canonical tuple when the child is not using an explicit direct endpoint. If the inherited tuple does not match, the child gets the provider-resolved runtime instead.

Tests

  • scripts/run_tests.sh tests/tools/test_delegate.py
  • .venv/bin/ruff check tools/delegate_tool.py tests/tools/test_delegate.py

Related

Complements #19623 and #25369.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists tool/delegate Subagent delegation comp/agent Core agent loop, run_agent.py, prompt builder labels May 14, 2026

@wesleysimplicio wesleysimplicio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read-only review pass: one remaining edge case seems to preserve the stale key this PR is trying to eliminate.

_normalize_child_runtime_tuple only repairs the inherited tuple when URL/mode/provider shape mismatches. If base_url and api_mode already match the resolved runtime but the inherited api_key is stale, the helper returns the old key. I reproduced this in a local read-only checkout by patching the resolver to return fresh-key; the helper still returned stale-key because no URL/mode mismatch was present.

I would include api_key mismatch in the repair condition whenever the resolver provides a key, plus a targeted regression for inherited stale key with matching base URL and API mode.

@dorukardahan

Copy link
Copy Markdown
Contributor Author

thanks, good catch. i added a follow-up commit that includes the api_key mismatch in the normalization condition and a regression test for the matching URL/mode case.\n\nwhile testing this on my live Hermes setup, i also found a related credential pool edge case: after a parent route switch, parent.provider can be openai-codex while the inherited pool is still from the previous provider. i added a small guard so child agents only share the parent pool when the pool provider matches too.\n\nlocal checks after the follow-up commit:\n- scripts/run_tests.sh tests/tools/test_delegate.py -> 132 passed\n- .venv/bin/ruff check tools/delegate_tool.py tests/tools/test_delegate.py -> passed

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

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists tool/delegate Subagent delegation type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants