fix(sdk): resolve gateway tools independently so one dead tool no longer fails the whole agent - #5813
Conversation
…ger fails the whole agent Gateway (Composio) tool resolution was all-or-nothing: the resolver sent every gateway reference in one batched POST /tools/resolve, so a single stale action that 404s (F-019) failed the entire batch and bricked the agent run at startup. Resolve each gateway config independently in ToolResolver instead. A tool that fails to resolve is dropped and recorded as a warning that names it (reusing the existing named GatewayToolResolutionError, which already carries the backend's 404 reason); the tools that resolve are kept and the run proceeds. The warnings are logged and returned on ResolvedToolSet.warnings so a degraded resolution is never silent. Non-gateway tools and the AgentaGatewayToolResolver HTTP contract are unchanged. Fixes #5173
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughSummary by CodeRabbit
WalkthroughGateway tools now resolve independently. HTTP 404 failures drop the affected tool and produce warnings, while successful tools remain available. Other gateway resolution failures still abort resolution. Unit and integration tests cover these outcomes. ChangesGateway resolution
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
Possibly related PRs
Sequence Diagram(s)sequenceDiagram
participant ToolResolver
participant GatewayResolver
participant GatewayBackend
participant ResolvedToolSet
ToolResolver->>GatewayResolver: Resolve each gateway tool
GatewayResolver->>GatewayBackend: Send tool-specific request
GatewayBackend-->>GatewayResolver: Return specification or HTTP status
GatewayResolver->>ResolvedToolSet: Keep valid tools and record 404 warnings
GatewayResolver-->>ToolResolver: Return resolved tools or raise non-404 error
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Railway Preview Environment
|
… failures The per-tool resolution loop caught every GatewayToolResolutionError and dropped the tool, which is too broad: a missing API base, a transport error, an HTTP 400, or a malformed backend response is systemic (it hits every tool), so swallowing it silently left the agent running with zero tools. It also broke the services integration suite (run-services-tests / integration), which asserts those systemic failures still propagate. Narrow the drop to error.status == 404 — the backend's ActionNotFoundError, the F-019 "action left the catalog" case, which is the only genuinely per-tool failure. Everything else re-raises and fails the run loudly, as before. Reconcile the integration tests with per-tool resolution: the old "joined_by_call_ref_not_position" test posted one batched request returning two specs, which no longer matches (each tool now resolves on its own call). The install_http fixture gains a per-request `responder` so a test can vary the response by call, and two new tests lock the fix in through the real gateway HTTP path: one dead action (404) is dropped with a naming warning while its sibling resolves, and a non-404 (400) failure still fails the whole run.
What
Gateway (Composio) tool resolution was all-or-nothing. When an agent has several gateway tools and one fails to resolve (for example a Composio action that has left the catalog and now 404s — the F-019 case), the entire agent run failed at startup.
The opaque-error half of this bug was fixed earlier (the error now names the failing action). This PR fixes the remaining half: one dead tool should degrade the agent, not brick it.
How
ToolResolver.resolveused to hand the whole batch of gateway configs to the resolver in one call; any single/tools/resolvenon-2xx failed all of them. It now resolves each gateway config independently (onegateway_resolver.resolve([config])call per tool) and collects failures:GatewayToolResolutionError(which already carries the backend's 404 reason and the actionable remedy).log.warning-surfaced and returned on the newResolvedToolSet.warnings, so a degraded resolution is never silent.The seam is deliberately one level above the HTTP adapter:
AgentaGatewayToolResolver's wire contract (batched request, per-ref validation, error shaping) is unchanged, and so is the behavior for non-gateway tools.Before / after
Test
Added
test_one_dead_gateway_tool_is_dropped_and_the_rest_resolve(and a clean-resolve companion) totest_resolver.py: given two gateway tools where one resolves and one 404s, the resolver returns the good tool plus a named warning and does not raise. Fullagents/toolsandagents/platformsuites pass (242 passed, 1 skipped); existingAgentaGatewayToolResolverHTTP tests are untouched and green.Fixes #5173