Skip to content

fix(anthropic_response): fail translation on malformed tool arguments (#550) - #874

Open
leseb wants to merge 1 commit into
praxis-proxy:mainfrom
leseb:leseb/validate-fix-issue-550
Open

fix(anthropic_response): fail translation on malformed tool arguments (#550)#874
leseb wants to merge 1 commit into
praxis-proxy:mainfrom
leseb:leseb/validate-fix-issue-550

Conversation

@leseb

@leseb leseb commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

When translating an OpenAI Chat Completions response into Anthropic Messages format, tool-call arguments that were not a valid JSON-encoded object were silently replaced with an empty object ({}), which could make an Anthropic client execute a tool with missing or default parameters. Translation now fails on malformed/non-object arguments instead of fabricating an executable tool_use block, and because the upstream status headers are already committed by the time the body is parsed, the original upstream response is preserved unchanged rather than emitting a misleading 200 OK error. This is the smallest complete change: a Result-returning transform plus unit, functional proxy, and controlled synthetic inference-fixture coverage.

Related issue

Closes #550

Validation

  • make lint — clippy, rustfmt, dependency, docs, example, and check-inference gates all pass.

  • make build

  • cargo test -p praxis-ai-apis --lib -- anthropic::to_openai::response — 21 passed, incl. invalid_tool_call_arguments_fail_transformation and non_object_tool_call_arguments_fail_transformation.

  • make test-inference-fixtures — coverage tests + all_inference_fixtures_replay pass.

  • cargo test -p praxis-tests-integration --test suite anthropic_to_openai_preserves_response_with_malformed_tool_arguments

  • Unit tests

  • Integration or functional tests

  • make lint

Checklist

  • I reviewed every changed line and can explain the change.
  • New capabilities include an example config and functional example test. (N/A — bug fix; reuses the existing anthropic/messages-to-openai.yaml example with a new functional test.)
  • User-facing behavior and generated documentation are updated.
  • Performance-sensitive changes include appropriate benchmark or load-test evidence. (N/A)
  • Commits are signed and include a Signed-off-by trailer.

Breaking changes

None. Previously a malformed tool-argument response produced a fabricated empty-input tool_use block; it now preserves the original upstream response so no valid tool_use is invented. Valid responses are unaffected.

…praxis-proxy#550)

When translating an OpenAI Chat Completions response into Anthropic
Messages format, tool call arguments that were not a valid JSON-encoded
object were silently replaced with an empty object (`{}`). That could
cause an Anthropic client to execute a tool with missing or default
parameters.

Translation now fails instead of fabricating an executable `tool_use`
block. Because upstream status headers are already committed by the time
the body is parsed, the original upstream response is preserved unchanged
rather than emitting a misleading error, which avoids accidental tool
execution without inventing a semantically incorrect response.

Adds unit, functional proxy, and controlled synthetic inference fixture
coverage.

Signed-off-by: Sébastien Han <seb@redhat.com>
@leseb
leseb requested review from a team and franciscojavierarceo September 2, 2026 10:43
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.

Malformed tool arguments are silently replaced with an empty object

1 participant