Conversation
Introduce ordered content blocks and ChatResult wrapping an assistant ChatMessage in Java and Python. Keep model result metadata separate from conversation content, structured output on ChatResponseEvent, and one tool call ID through tool execution and history. Update the execution flow and direct contract tests. This is the core design review commit. No backward compatibility with the previous chat API is retained. The series is grouped by review responsibility; apply all three commits together for full-repository buildability. Refs apache#1056 Generated-by: Codex 0.153.4 (GPT-6) Co-authored-by: Codex <codex@openai.com>
Migrate Ollama, OpenAI, Azure, Anthropic, Gemini, Bedrock, Watsonx, Tongyi and related adapters to the new chat contracts. Preserve provider-native reasoning signatures and encrypted content for replay, and map typed tool calls/results. Keep stateless SDK conversions in provider utility methods, with local protocol constants. Include provider parsing, request and reasoning replay tests. The series is grouped by review responsibility; apply all three commits together for full-repository buildability. Refs apache#1056 Generated-by: Codex 0.153.4 (GPT-6) Co-authored-by: Codex <codex@openai.com>
Update Java/Python resource bridges, ReAct and routing consumers, prompts, tools, memory and event logging to the new chat contracts. Migrate downstream tests, cross-language event snapshots, examples, YAML consumers and docs. These changes follow the core and provider contracts in the preceding commits. The series is grouped by review responsibility; apply all three commits together for full-repository buildability. Refs apache#1056 Generated-by: Codex 0.153.4 (GPT-6) Co-authored-by: Codex <codex@openai.com>
wenjin272
force-pushed
the
codex/chat-message-refactor
branch
from
October 1, 2026 08:10
e0d4f8a to
4f26d55
Compare
wenjin272
marked this pull request as ready for review
October 1, 2026 12:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked issue: Closes #1056
Purpose of change
Outcome and runtime flow
Represent conversation content as ordered typed blocks in Java and Python. Chat models return
ChatResult, containing an assistantChatMessage, model/response identifiers, token usage, finish reason and result metadata. This separates conversation history from per-invocation output previously mixed intoextra_argsand untyped tool-call maps.ChatRequestEvent-> chat action -> provider adapter ->ChatResult. The action reads usage and finish reason, stores only the assistant message in history, and dispatches typed tool calls. Tool execution returnsToolResponse; history records its model-facing content asToolResultBlockunder the same call ID. Structured output and routing information remain onChatResponseEvent.Key decisions and review order
The three commits group core contracts/execution, provider adaptations, and downstream consumers/bridges/fixtures. Review the first two for design and protocol behavior; apply the complete series for repository buildability.
Keep
ToolResponseseparate fromToolResultBlock: execution status and timing are distinct from model-facing conversation content. Keep ordinary mutable metadata/input maps without deep-freezing arbitrary values. Stateless provider conversions use local static utilities, with protocol field constants.Behavioral Semantics
Interaction decisions
Contracts and failure behavior
Tests
After rebasing onto main (
99103da67): full Java reactor compilation/install succeeded; Java non-E2E tests passed (2627 passed, 44 skipped), excludingFlussActionStateStoreIntegrationTestbecause its embedded service previously blocked during initialization. Python non-integration tests: 1707 passed, 14 skipped. Anthropic parsing tests also passed against CI SDK version 1.11.0 (96 tests); the mocked Tongyi call-ID round trip and both MCP input-action paths passed (3 tests). Prompt-driven example action regressions cover three agents. Mock chat MiniCluster E2E: 2 passed. Spotless and Ruff checks for changed files passed.Not verified: live model services, exhaustive parity across providers, and upgrade/recovery from the old message wire format. This PR intentionally breaks that format.
API
Breaking Java/Python change: chat methods return
ChatResult; replaceextra_args/extraArgsand untypedtool_callswith typed blocks and scoped metadata. History still consists ofChatMessage; text convenience factories remain available. Use event structured-output accessors for parsed results. Existing serialized messages/events/checkpoints require migration; no compatibility layer is provided.Documentation
doc-neededdoc-not-neededdoc-includedWas this patch authored or co-authored using generative AI tooling?
Generated-by: Codex 0.153.4 (GPT-6)