Skip to content

[API][Tool] Align Java and Python Tool outcome contracts - #1074

Open
joeyutong wants to merge 3 commits into
apache:mainfrom
joeyutong:codex/align-tool-outcomes
Open

[API][Tool] Align Java and Python Tool outcome contracts#1074
joeyutong wants to merge 3 commits into
apache:mainfrom
joeyutong:codex/align-tool-outcomes

Conversation

@joeyutong

@joeyutong joeyutong commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Linked issue: #956

Purpose of change

Java can distinguish whether a Tool invocation returned from whether the returned ToolResponse represents a successful Tool operation. Python previously exposed only raw return values, so every normal return was recorded as a successful Tool operation.

This change aligns the Java and Python Tool outcome contracts:

  • adds Python ToolResponse.success(...) and ToolResponse.error(...) while preserving raw Python returns as successful results;
  • normalizes sequential and parallel Python Tool calls through the same result-recording path;
  • preserves explicit Tool outcomes across both Java-to-Python and Python-to-Java bridges without inspecting arbitrary user payloads;
  • records missing Skill resources and MCP protocol error results as failed Tool operations while retaining their existing model-facing messages;
  • keeps Outcome<T> focused on whether the durable invocation returned or raised.

ToolResponseEvent, Execution Events, and downstream metrics can therefore consume the same normalized Tool outcome in both languages. The existing ToolResponseEvent.responses wire representation is unchanged.

Tests

  • mvn -pl api,plan,runtime,integrations/mcp -am -DskipITs test
  • pytest for the affected Python Tool API, Tool call, MCP, Skill, and Java bridge suites (66 passed)
  • Ruff format and lint checks for all changed Python files

API

Adds the public Python flink_agents.api.tools.ToolResponse type. Existing Python Tools that return raw values remain source- and behavior-compatible.

Documentation

  • doc-needed
  • doc-not-needed
  • doc-included

Was this patch authored or co-authored using generative AI tooling?

  • Yes
  • No

Generated-by: Codex 0.151.0-alpha.7.2 (GPT-5.6 Sol)

@github-actions github-actions Bot added doc-included Your PR already contains the necessary documentation updates. fixVersion/0.4.0 priority/major Default priority of the PR or issue. and removed doc-included Your PR already contains the necessary documentation updates. labels Aug 31, 2026
汤雨 and others added 3 commits August 31, 2026 15:53
Preserve explicit Tool operation failures across native and cross-language
execution without changing existing raw Python Tool return behavior.

Generated-by: Codex 0.151.0-alpha.7.2 (GPT-5.6 Sol)
Co-Authored-By: Claude Code <[email protected]>
AI-Model: gpt-5.6-sol
AI-Contributed/Feature: 274/274
AI-Contributed/UT: 315/315
Use error and is_error consistently with the established Java ToolResponse
contract while keeping the bridge wire field named error.

Generated-by: Codex 0.151.0-alpha.7.2 (GPT-5.6 Sol)
Co-Authored-By: Claude Code <[email protected]>
AI-Model: gpt-5.6-sol
AI-Contributed/Feature: 28/28
AI-Contributed/UT: 24/24
Keep Java ToolResponse success and error states intact across the Java-to-Python bridge, preserve empty error messages, and add symmetric bridge coverage.

Generated-by: Codex 0.151.0-alpha.7.2 (GPT-5.6 Sol)
Co-Authored-By: Claude Code <[email protected]>
AI-Model: gpt-5.6-sol
AI-Contributed/Feature: 53/53
AI-Contributed/UT: 148/148
@joeyutong
joeyutong force-pushed the codex/align-tool-outcomes branch from 82adfd8 to a186ab5 Compare August 31, 2026 08:09
@github-actions github-actions Bot added doc-included Your PR already contains the necessary documentation updates. and removed doc-included Your PR already contains the necessary documentation updates. labels Aug 31, 2026
@joeyutong
joeyutong marked this pull request as ready for review August 31, 2026 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-included Your PR already contains the necessary documentation updates. fixVersion/0.4.0 priority/major Default priority of the PR or issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant