[runtime][plan][python] Add built-in operational metrics - #955
Draft
joeyutong wants to merge 11 commits into
Draft
[runtime][plan][python] Add built-in operational metrics#955joeyutong wants to merge 11 commits into
joeyutong wants to merge 11 commits into
Conversation
added 9 commits
July 24, 2026 10:22
Treat eventAttributes as the payload root and document durable replay limitations. Co-Authored-By: Codex <noreply@openai.com> AI-Model: gpt-5 AI-Contributed/Feature: 59/59 AI-Contributed/UT: 28/28
Report raw Action errors as failed and emit successful Action completion before processing emitted Events. Co-Authored-By: Codex <noreply@openai.com> AI-Model: gpt-5 AI-Contributed/Feature: 3/3 AI-Contributed/UT: 0/0
Keep Event Log writes best-effort while exposing failures through a counter and a first-failure warning. Attempt flush independently after append failures and surface PrintWriter I/O errors. Co-Authored-By: Codex <noreply@openai.com> AI-Model: gpt-5 AI-Contributed/Feature: 57/57 AI-Contributed/UT: 43/43
Document execution lifecycle event level overrides, the flat Event Log field migration, and Python per-occurrence Event IDs. Co-Authored-By: Codex <noreply@openai.com> AI-Model: gpt-5 AI-Contributed/Feature: 11/11 AI-Contributed/UT: 0/0
Follow only explicitly chained Python causes so failure attribution matches Java Throwable.getCause semantics. Co-Authored-By: Codex <noreply@openai.com> AI-Model: gpt-5 AI-Contributed/Feature: 2/2 AI-Contributed/UT: 29/29
Assert that STANDARD payload truncation leaves the top-level Event ID unchanged. Co-Authored-By: Codex <noreply@openai.com> AI-Model: gpt-5 AI-Contributed/Feature: 0/0 AI-Contributed/UT: 4/4
Derive input-run, Action, LLM, Tool, Skill, and MCP metrics from runtime lifecycle boundaries. Rebuild current-count gauges from Flink state and align Java and Python retry metrics under the model resource scope. Co-Authored-By: Codex <noreply@openai.com> AI-Model: gpt-5 AI-Contributed/Feature: 2/2 AI-Contributed/UT: 0/0
joeyutong
force-pushed
the
codex/agent-operational-metrics-pr
branch
from
August 3, 2026 11:33
faddd6f to
934c1ce
Compare
2 tasks
Document the current Java and Python Tool result mappings and link the follow-up alignment work. Co-Authored-By: Codex <noreply@openai.com> AI-Model: gpt-5 AI-Contributed/Feature: 2/2 AI-Contributed/UT: 0/0
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.
What changed
This PR implements the built-in operational metrics proposed in Discussion #901.
It depends on #924, which introduces the execution lifecycle and trace context consumed by these metrics. The PR is opened as a draft and will be rebased onto
mainafter #924 is merged. Until then, the Metrics-only diff is available in this branch comparison.Runtime lifecycle integration
ActionExecutionOperatorrecords input queue, input-run, Action task, and Action execution boundaries at the points where they actually occur.OperatorStateManagerexposes pending Action state for restoring current-count gauges after task recovery.BuiltInMetricsis the central dispatcher. Action lifecycle events feed Action metrics, while LLM and Tool lifecycle events feed execution-entity metrics. Event Log writing and metric aggregation consume the same in-process execution event independently.Metric implementations
BuiltInInputRunMetricsrecords run outcomes, end-to-end, queue, and processing latency, pending input Events, and active input runs.BuiltInActionMetricsrecords scheduling and logical execution latency, pending Action tasks, and active Action executions.BuiltInExecutionMetricspairs execution start and terminal events by execution id, then dispatches by entity type.LlmExecutionMetricRecorderrecords model-resource success, failure, and latency.ToolExecutionMetricRecorderrecords Tool metrics and projects explicit Skill and MCP Server metadata into their own scopes.Tool outcomes retain the existing language-specific contracts. Java maps an unsuccessful
ToolResponseto failure. Python maps resource preparation and invocation exceptions to failure, while a normal arbitrary return remains successful because Python currently has no explicit error-result type. Strict alignment is tracked in #956 and is planned after the parallel Tool-call work in #926. This PR retains the Tool and MCP outcome counters and does not infer failure from arbitrary return payloads.Java and Python ChatModel paths
model_resourcescope in both Java and Python, including final-failure andIGNOREpaths.modelscope.Metric scope and documentation
Validation
mvn -T4 -B --no-transfer-progress spotless:checkmvn -B --no-transfer-progress -pl plan,runtime -am -DskipITs -Dtest=ChatModelActionRetryTest,CompileUtilsTest,BuiltInActionMetricsTest,BuiltInExecutionMetricsTest,BuiltInInputRunMetricsTest,ActionExecutionOperatorTest -Dsurefire.failIfNoSpecifiedTests=false testuv run ruff check flink_agents/plan/actions/chat_model_action.py flink_agents/plan/tests/actions/test_chat_model_action_retry.pypython -m pytest -q flink_agents/plan/tests/actions/test_chat_model_action_retry.pyRelated work