fix(pi): name why an agent run aborted - #1249
Open
Gilbert09 wants to merge 1 commit into
Open
Conversation
Both pi entry points fire one `agent aborted` event from several unrelated terminal paths: a security termination, a run that made no tool call, a run that left its own plan open, a rate limit, and a generic gateway error. The event carried only duration and model, so every one of those arrived as the same unlabelled abort. The linear sequence's own `agent aborted` has carried a `reason` all along. The discriminator was already in hand at every call site — each one returns an `AgentErrorType` on the next line — so `captureAborted` now takes it and stamps it on the event. The value is a closed enum, so no free text reaches telemetry. The two entry points classified a thrown message with the same two needles, inline and *after* the capture, which is why the type was not available to the event. That classification moves to `runErrorType` in `completion.ts`, next to `completionFailure`, and is unit-tested there. Generated-By: PostHog Desktop Task-Id: 0af1c1f6-2aab-4807-8e24-86b2a9eb18fd
🧙 Wizard CIRun the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands: Test all apps:
Test all apps in a directory:
Test an individual app:
Show more apps
Test against a Context Mill branch:
Add Results will be posted here when complete. |
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.
Problem
Both pi entry points —
piBackend.runandrunPiTask, the one the orchestratordrives — fire a single
agent abortedevent from several unrelated terminalpaths:
The event carried only
duration_*andmodel, so all five arrived as the sameunlabelled abort. In the current data for the data-source setup flow,
agent abortedshows up with an empty reason dimension, alongside an equal number oftasks failed as
no-report— the same runs, seen from the queue's side. A taskagent that died can be counted but not diagnosed, and one of the five causes is a
security termination on the one step that handles live credentials.
The linear sequence's own
agent abortedhas carried areasonall along; onlythe pi harness omits it.
Why
Came out of reading the telemetry for the wizard's data-source setup task. This
does not change the funnel — it makes the handful of runs that end this way
attributable, so the next read of that telemetry can tell a security stop from a
rate limit instead of guessing.
Changes
captureAbortedtakes theAgentErrorTypethe path is about to return andstamps it as
reason. The discriminator was already in hand at every callsite — each returns that type on the next line. It is a closed enum, so no
free text reaches telemetry.
inline and after the capture, which is why the type was not available to the
event. That moves to
runErrorTypeincompletion.ts, besidecompletionFailure, and is unit-tested there.No behaviour changes for the user: every path returns exactly the same
AgentResultas before.Related but not the same fix: #1109
touches these two lines to add an
abort_kindthat separates a pi run-incompleteevent from the linear
[ABORT]one. It is a constant per site, so it does notsay which pi path fired. The two are complementary.
Test plan
runErrorTypeunit tests added to the existingcompletion.test.ts.vitest run src/lib/agent/runner/harness/pi— 127 tests pass.tsc --noEmitintroduces no new errors in the harness; prettier and eslintclean on the touched files.
Created with PostHog Desktop