Skip to content

fix(agents)!: KG-809. Add duration to AIAgentPipeline events#2040

Open
sdubov wants to merge 1 commit into
developfrom
sdubov/KG-809
Open

fix(agents)!: KG-809. Add duration to AIAgentPipeline events#2040
sdubov wants to merge 1 commit into
developfrom
sdubov/KG-809

Conversation

@sdubov
Copy link
Copy Markdown
Collaborator

@sdubov sdubov commented May 19, 2026

  • Thread "duration" through every Completed, Failed, AgentClosing pipeline event: trigger functions, context classes, and the matching serialized wire-format events;
  • Measure each window at the call site in AIAgentRunSessionImpl, AIAgentNode, AIAgentSubgraph, AIAgentPlanner, ContextualPromptExecutor, and ContextualAgentEnvironment. Marks are captured close to the actual work, after the *Starting hook returned.
  • duration is nullable on the three events that can fire before measurement begins (AgentExecutionFailed*, LLMStreamingFailed*, LLMStreamingCompleted*);
  • Tracing and Debugger forward eventContext.duration into the wire-format events;
  • Add PipelineDurationTest covering: non-negative durations on all completion events, closing ≥ completed invariant, non-null on mid-strategy failure, null sentinel when onAgentStarting throws;
  • Update docs/docs/agent-events.md with the new duration column per event.

BREAKING: duration is required on *CompletedEvent/*FailedEvent/AgentClosingEvent, constructors; nullable on AgentExecutionFailed*, LLMStreamingFailed*, LLMStreamingCompleted*.

closes: KG-809

- Thread "duration" through every Completed, Failed, AgentClosing pipeline event: trigger functions, context classes, and the matching serialized wire-format events;
- Measure each window at the call site in `AIAgentRunSessionImpl`, `AIAgentNode`, `AIAgentSubgraph`, `AIAgentPlanner`, `ContextualPromptExecutor`, and `ContextualAgentEnvironment`. Marks are captured close to the actual work, after the `*Starting` hook returned.
- duration is nullable on the three events that can fire before measurement begins (`AgentExecutionFailed*`, `LLMStreamingFailed*`, `LLMStreamingCompleted*`);
- `Tracing` and `Debugger` forward `eventContext.duration` into the wire-format events;
- Add `PipelineDurationTest` covering: non-negative durations on all completion events, closing ≥ completed invariant, non-null on mid-strategy failure, `null` sentinel when `onAgentStarting` throws;
- Update `docs/docs/agent-events.md` with the new `duration` column per event.

BREAKING: `duration` is required on `*CompletedEvent`/`*FailedEvent`/`AgentClosingEvent`, constructors; nullable on `AgentExecutionFailed*`, `LLMStreamingFailed*`, `LLMStreamingCompleted*`.

closes: [KG-809](https://youtrack.jetbrains.com/issue/KG-809)
@sdubov sdubov self-assigned this May 19, 2026
@sdubov sdubov requested a review from EugeneTheDev May 19, 2026 15:28
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.

1 participant