[api][runtime][python] Add Agent Trace recording to Event Log#924
Open
joeyutong wants to merge 3 commits into
Open
[api][runtime][python] Add Agent Trace recording to Event Log#924joeyutong wants to merge 3 commits into
joeyutong wants to merge 3 commits into
Conversation
joeyutong
marked this pull request as ready for review
July 24, 2026 02:33
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 discussion: #900
Related: #710, #841, #923
Purpose of change
This PR implements the recording side of Agent Trace proposed in #900.
The existing Event Log records business Events but does not provide enough runtime context to identify one input run, distinguish concrete Action/LLM/Parser/Tool executions, reconstruct nested execution relationships, or attribute execution failures.
This PR adds execution identity and lifecycle recording to the existing Event Log path. It complements the business Event lineage implemented in #923 rather than defining another Event-to-Action lineage field:
executionId, connecting the two models.API and trace model
ExecutionTraceContextcarries run identity, execution hierarchy, entity identity, and entity metadata.ExecutionLifecycleEventsdefinesstarted,finished,failed, andreusedlifecycle Events.ExecutionReporterandExecutionReportersprovide an optional, best-effort capability for reporting nested executions.ToolExecutionMetadataProviderallows Tools to contribute small structured execution metadata.EventLoggeraccepts an optionalExecutionTraceContext; its default overload preserves compatibility with existing implementations.AgentPlancarries the Agent name used by trace records.event-log.trace.enabledcontrols Trace persistence and defaults tofalse.Runtime integration
ActionExecutionOperatorcreates one run context per processed input and one execution context per Action invocation.ActionTaskcarries the Action execution context and started-event marker across continuations and Flink state restoration.ActionTaskContextManagerkeeps child-execution start/terminal pairing transient and scoped by Action execution id across live continuation tasks.reusedwhen completed Action state is reused.EventRouter.ExecutionEventSinkwithout automatically submitting them to the business Event routing path.RunnerContextImplimplementsExecutionReporter, creates child execution contexts, and pairs start and terminal reports.ExecutionEventLoggersends Execution Events to the sharedEventLogWriter.EventLogWriterowns logger open, append, flush, and close operations; write failures remain best-effort.Action and resource instrumentation
ChatModelActionrecords one LLM execution per framework model invocation.ToolCallActionrecords one Tool execution per concrete tool call, including error responses and thrown exceptions.load_skillcalls record the loaded Skill as Tool execution metadata.Python alignment
ExecutionReportercapability and entity/problem vocabulary as Java.Event Log format and compatibility
EventLogRecordcombinesEventContext, optionalExecutionTraceContext, andEvent.The JSONL representation is flattened for querying and aggregation. Framework-owned fields retain the existing camelCase convention, including
eventType,eventAttributes,inputRunId, andexecutionId. The record includes Event occurrence fields, run identity, execution hierarchy, entity information, lifecycle status, failure category, and Event attributes.The framework deserializer continues to read the previous nested Event Log format. Existing external consumers that parse the raw JSON shape must migrate to the normalized field names.
Trace persistence is disabled by default. When disabled, business Events continue to be logged without trace context and Execution Events are not persisted.
A restored
ActionTaskretains its run and execution identities. A source-replayed input not represented by restored Action state starts a new run.This PR changes the pending
ActionTaskstate schema. Restoring savepoints containing that state from before this change would require a versionedActionTaskstate serializer, which is outside this PR.Tests
mvn -pl runtime -am -DskipITs testAPI
This PR introduces the public Trace APIs described above and extends
EventLoggerwith a backward-compatible default overload accepting optional trace context.The normalized raw Event Log JSON shape is a compatibility change for external consumers. Legacy records remain readable through the framework deserializer.
Documentation
doc-neededdoc-not-neededdoc-included