-
Notifications
You must be signed in to change notification settings - Fork 52.6k
fix: derive delegation api_mode from delegation model, not main model #6647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -801,12 +801,27 @@ def _resolve_delegation_credentials(cfg: dict, parent_agent) -> dict: | |
| f"Set the appropriate environment variable or run 'hermes auth'." | ||
| ) | ||
|
|
||
| api_mode = runtime.get("api_mode") | ||
|
|
||
| # Fix: when delegation uses copilot with a different model than the main | ||
| # agent, the api_mode resolved by resolve_runtime_provider is based on the | ||
| # main model (model.default in config). We must re-derive it for the | ||
| # delegation model. E.g. main model gpt-5.4 → codex_responses, but | ||
| # delegation model gpt-4.1 → chat_completions. Without this, the | ||
| # subagent sends gpt-4.1 to the Responses API which returns HTTP 400. | ||
| if configured_model and configured_provider in ("copilot",): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please move this target-model selection into the shared Copilot runtime resolver instead. Current main already forwards |
||
| try: | ||
| from hermes_cli.models import copilot_model_api_mode | ||
| api_mode = copilot_model_api_mode(configured_model, api_key=api_key) | ||
| except Exception: | ||
| api_mode = "chat_completions" | ||
|
|
||
| return { | ||
| "model": configured_model, | ||
| "provider": runtime.get("provider"), | ||
| "base_url": runtime.get("base_url"), | ||
| "api_key": api_key, | ||
| "api_mode": runtime.get("api_mode"), | ||
| "api_mode": api_mode, | ||
| "command": runtime.get("command"), | ||
| "args": list(runtime.get("args") or []), | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fake key is passed to
copilot_model_api_mode()by the new implementation, which fetches the live Copilot catalog wheneverapi_keyis non-empty (hermes_cli/models.py:3312-3315). Please mockfetch_github_model_catalog(or otherwise supply a static catalog) so this regression test remains hermetic.