Skip to content

fix(http-request): accept any-case pair keys and return model-fixable errors - #1126

Merged
ionut-mihalache-uipath merged 1 commit into
mainfrom
fix/http-tool-recoverable-errors
Oct 1, 2026
Merged

ionut-mihalache-uipath merged 1 commit into
mainfrom
fix/http-tool-recoverable-errors

Conversation

@ionut-mihalache-uipath

Copy link
Copy Markdown
Contributor

Why

Agents using the HTTP Request tool failed at random with AGENT_RUNTIME.INVALID_INPUT_ARGUMENT:

headers.0.name  Field required [type=missing, input_value={'Name': 'Accept', 'Value': 'text/html'}]

The schema expects {"name", "value"} pairs, but models sometimes write {"Name", "Value"}, and pydantic matches keys case-sensitively. Because non-conversational agents have no node-level tool error handling, one malformed call out of many ended the whole job, and the model never got to retry.

What

  • Pair keys in any case. A new _HttpRequestTool subclass lowercases name/value keys in headers and params before validation. Only the keys change; header and param values keep their case, so tokens and case-sensitive query values are untouched. _pairs_to_dict does the same lookup for input that skips validation.
  • Model-fixable errors go back to the model. The tool now raises LangChain's ToolException and sets handle_tool_error=True, so these come back as ToolMessage(status="error") and the run continues:
    • schema mismatches that remain after the key fix (via an _invalid_input_error override)
    • a missing or non-string url
    • an unsupported method or a bad timeout
    • an SSRF-blocked host (the request is still blocked; only how the refusal is reported changes)
    • a host that doesn't resolve
    • timeouts and other httpx transport errors
  • BaseUiPathStructuredTool._invalid_input_error has a wider return type (-> Exception). Other tools behave exactly as before.

Tests

  • New tests cover mixed-case pair keys (values keep their case), schema mismatches returned to the model, read and connect errors, and a bad call through create_tool_node. That last one is the non-conversational graph path, which now yields an error tool message instead of raising.
  • The existing "raises" tests now assert an error tool message.
  • tests/agent: 2281 passed, 3 skipped. ruff, mypy and lint_httpx_client.py are clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_016T19pn6oVDUNv9YHzgQQUP

… errors

Models sometimes write header and param pairs as {"Name", "Value"}. The
schema keys are lowercase and pydantic matches them case-sensitively, so
the call failed validation and faulted the run. The pair keys are now
lowercased before validation; header and param values keep their case.

Errors the model can correct (schema mismatches, a bad url, method or
timeout, a blocked or unresolvable host, timeouts and connection errors)
are raised as ToolException with handle_tool_error on, so they come back
as an error tool message instead of faulting the run. Non-conversational
agents have no node-level error handling, so a single bad call ended the
whole job.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016T19pn6oVDUNv9YHzgQQUP
Copilot AI balanced review requested due to automatic review settings October 1, 2026 13:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation matches the stated behavior and includes focused coverage for the affected execution paths.

Review effort: Balanced
Findings: None

What changed in this PR

Improves HTTP Request tool resilience so agents can recover from casing mistakes and model-fixable failures.

Changes:

  • Normalizes header and parameter pair keys case-insensitively.
  • Returns validation, network, and SSRF errors as error ToolMessage responses.
  • Adds coverage for normalization and non-conversational tool-node behavior.
File Description
http_request_tool.py Adds normalization and recoverable error handling.
base_uipath_structured_tool.py Broadens validation-error return typing.
test_http_request_tool.py Tests successful normalization and error responses.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@sonarqubecloud

sonarqubecloud Bot commented Oct 1, 2026

Copy link
Copy Markdown

@ionut-mihalache-uipath
ionut-mihalache-uipath merged commit b219d8c into main Oct 1, 2026
47 of 49 checks passed
@ionut-mihalache-uipath
ionut-mihalache-uipath deleted the fix/http-tool-recoverable-errors branch October 1, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants