Skip to content

Bugfix: preserve delegation api_mode for custom endpoints#10273

Closed
HiddenPuppy wants to merge 3 commits into
NousResearch:mainfrom
HiddenPuppy:codex/fix-delegation-custom-api-mode
Closed

Bugfix: preserve delegation api_mode for custom endpoints#10273
HiddenPuppy wants to merge 3 commits into
NousResearch:mainfrom
HiddenPuppy:codex/fix-delegation-custom-api-mode

Conversation

@HiddenPuppy

Copy link
Copy Markdown
Contributor

Summary

This fixes delegation provider resolution for direct custom endpoints so subagents keep the correct wire protocol when delegation.base_url is configured.

Fixes #10213.

Root Cause

tools.delegate_tool._resolve_delegation_credentials() ignored delegation.api_mode for direct endpoints and used a narrower URL heuristic than the main provider runtime. Anthropic-compatible endpoints like Microsoft Foundry could therefore be misclassified as chat_completions, which sent subagent requests to the wrong path.

What Changed

  • honor an explicit delegation.api_mode for direct endpoints
  • reuse the shared provider API-mode detection for custom base URLs
  • add regression tests for Anthropic-compatible custom delegation endpoints

Validation

  • python -m pytest tests/tools/test_delegate.py -k "direct_endpoint_respects_explicit_api_mode or direct_endpoint_auto_detects_anthropic_suffix or direct_anthropic_endpoint_reaches_child_agent_with_anthropic_api_mode or direct_endpoint_credentials_reach_child_agent" -q
  • python -m pytest tests/tools/test_delegate.py -k "TestDelegationCredentialResolution or TestDelegationProviderIntegration" -q

@HiddenPuppy HiddenPuppy force-pushed the codex/fix-delegation-custom-api-mode branch from 5ef410c to 03b4b65 Compare April 15, 2026 13:33
@teknium1

Copy link
Copy Markdown
Contributor

Thanks @HiddenPuppy! Salvaged into PR #26824 — merged as c445f48. Your authorship is preserved via the Co-Authored-By trailer on the merge commit.

Your branch was stale enough that a direct cherry-pick would have brought in unrelated workflow/plugin-test changes already landed on main, so I reimplemented the substantive fix in delegate_tool.py against current main and used _detect_api_mode_for_url() (the shared helper the main agent's runtime resolver already uses) instead of determine_api_mode for consistency. The behavioral outcome matches your fix.

Closing this in favor of #26824.

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

Labels

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.

[Bug]: Improved Integration for Microsoft Foundry

3 participants