Repository navigation
feat(agent): record how long each todo of a run took - #1812
Merged
Merged
Conversation
The session stamps a todo when it starts and when it completes, matched by id from one TodoWrite call to the next, and adds up the stretches it was in progress for. The times ride on the todos state and in the chat's todo list, and a headless run's terminal event reports its wall time split between its todos.
Contributor
|
🎉 This PR is included in version 0.255.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Summary
A run now shows where its time went. The session stamps each todo when it starts and when it completes, and adds up the stretches it was in progress for. The model supplies none of it and cannot overwrite it.
started_at,completed_atandelapsed_msresultofRUN_FINISHEDreportstodoTimes: the run's wall time split between its todos and the time no todo was in progressRun on the mock gateway with a scripted session of three
TodoWritecalls around two sleeps:Closes #1807
Changes
internal/agent/domain-TodoItemgains the three fields.StampTodoscarries a list's times over by id and stamps a status that changed, andTodoItem.ElapsedAtis the time worked on by a given momentinternal/agent/loop/agent.go-recordTodosstamps aTodoWriteresult against the session's list at the one place the loop records it, under a lock so two calls of one turn stamp in order. The stamped list is what the tool result, the state store and the todo event carryinternal/presentation/headless-todoClockattributes the run's wall time to the todo in progress at each moment. The run encoder feeds it the todo updates and adds its summary to the terminal event's resultinternal/presentation/tui/components/todo_box_view.go- the elapsed time beside an itemdocs/tools-reference.mdanddocs/ag-ui-output.mdA run that never calls
TodoWritepublishes and reports exactly what it did before: the new fields areomitemptyandtodoTimesis left out.Differences from the issue
TodoWriteis called, so the item in progress carriesstarted_atand what it gathered before, and a client adds the time sincestarted_at. The issue asked that a client need not compute it - for finished stretches it does notTodoWriteresult in the conversation, but a resumed session does not restore its todo list today, with or without times. Restoring it is a change of its ownrunMswithin a millisecond, as each is rounded down to whole millisecondsidgets a new one on every call, as before, so its time starts overDocs follow-up
A
[DOCS]issue for inference-gateway/docs is drafted, not filed: the three fields on a todo andtodoTimeson the AG-UI output page.