Skip to content

fix(sdk): resolve gateway tools independently so one dead tool no longer fails the whole agent - #5813

Merged
mmabrouk merged 2 commits into
release/v0.112.0from
fix/composio-partial-resolution-5173
Aug 10, 2026
Merged

fix(sdk): resolve gateway tools independently so one dead tool no longer fails the whole agent#5813
mmabrouk merged 2 commits into
release/v0.112.0from
fix/composio-partial-resolution-5173

Conversation

@mmabrouk

@mmabrouk mmabrouk commented Aug 7, 2026

Copy link
Copy Markdown
Member

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.resolve used to hand the whole batch of gateway configs to the resolver in one call; any single /tools/resolve non-2xx failed all of them. It now resolves each gateway config independently (one gateway_resolver.resolve([config]) call per tool) and collects failures:

  • 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 and the actionable remedy).
  • The tools that do resolve are kept and the run proceeds.
  • Warnings are log.warning-surfaced and returned on the new ResolvedToolSet.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

  • Before: two gateway tools, one 404s → resolution raises → whole agent run fails at startup.
  • After: two gateway tools, one 404s → the good tool resolves, the dead one is dropped with a named warning, the run proceeds.

Test

Added test_one_dead_gateway_tool_is_dropped_and_the_rest_resolve (and a clean-resolve companion) to test_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. Full agents/tools and agents/platform suites pass (242 passed, 1 skipped); existing AgentaGatewayToolResolver HTTP tests are untouched and green.

Fixes #5173

…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
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Aug 7, 2026
@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenta-documentation Error Error Aug 10, 2026 4:29pm

Request Review

@dosubot dosubot Bot added bug report Something isn't working python Pull requests that update Python code labels Aug 7, 2026
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 6c8231b7-8a62-4f89-9051-0d5071a519a3

📥 Commits

Reviewing files that changed from the base of the PR and between 4ff4d1e and 49f20e9.

📒 Files selected for processing (5)
  • sdks/python/agenta/sdk/agents/tools/models.py
  • sdks/python/agenta/sdk/agents/tools/resolver.py
  • sdks/python/oss/tests/pytest/unit/agents/tools/test_resolver.py
  • services/oss/tests/pytest/integration/agent/conftest.py
  • services/oss/tests/pytest/integration/agent/tools/test_gateway_http.py

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Gateway tools are now resolved independently, allowing available tools to remain usable when another tool is unavailable.
    • Missing gateway actions are skipped with clear, human-readable warnings.
    • Successfully resolved tools retain their associated metadata.
  • Bug Fixes

    • Gateway tool matching is now based on each tool’s reference, improving resolution accuracy.
    • Unexpected gateway errors continue to stop resolution and report a typed failure.

Walkthrough

Gateway 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.

Changes

Gateway resolution

Layer / File(s) Summary
Resolution contract and partial gateway handling
sdks/python/agenta/sdk/agents/tools/models.py, sdks/python/agenta/sdk/agents/tools/resolver.py
ResolvedToolSet now stores warnings. Gateway tools resolve independently. HTTP 404 failures are logged, omitted, and reported as warnings. Other failures are re-raised.
Unit coverage for partial resolution
sdks/python/oss/tests/pytest/unit/agents/tools/test_resolver.py
Tests verify that failed tools are omitted, valid tools remain, warnings include failure details, and clean resolution returns no warnings.
HTTP integration coverage
services/oss/tests/pytest/integration/agent/conftest.py, services/oss/tests/pytest/integration/agent/tools/test_gateway_http.py
The HTTP fixture supports request-specific responses. Integration tests cover per-tool requests, metadata preservation, HTTP 404 drops, and non-404 failures.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

  • Agenta-AI/agenta issue 5174 — It addresses partial gateway resolution for HTTP 404 failures and warning reporting.

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
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.00% which is insufficient. The required threshold is 60.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change: independent gateway tool resolution prevents one failed tool from failing the entire agent.
Description check ✅ Passed The description directly explains the gateway resolution problem, implementation, behavior, tests, and linked issue.
Linked Issues check ✅ Passed The changes satisfy issue #5173 by dropping failed 404 gateway tools, preserving valid tools, and surfacing named warnings.
Out of Scope Changes check ✅ Passed The code and test changes remain within the gateway resolution objectives, including focused fixture updates for per-request integration tests.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/composio-partial-resolution-5173

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Image tag pr-5813-870921f
Status Failed
Logs View workflow run
Updated at 2026-08-10T16:46:12.338Z

@mmabrouk mmabrouk left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

lgtm

@mmabrouk mmabrouk added the lgtm This PR has been approved by a maintainer label Aug 10, 2026
@mmabrouk
mmabrouk changed the base branch from release/v0.110.0 to release/v0.112.0 August 10, 2026 16:17
… 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.
@mmabrouk
mmabrouk merged commit 545b477 into release/v0.112.0 Aug 10, 2026
42 of 43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug report Something isn't working lgtm This PR has been approved by a maintainer python Pull requests that update Python code size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant