agent_end: auto-complete in_progress tasks when LLM finishes turn#10
Closed
ZGltYQ wants to merge 1 commit into
Closed
agent_end: auto-complete in_progress tasks when LLM finishes turn#10ZGltYQ wants to merge 1 commit into
ZGltYQ wants to merge 1 commit into
Conversation
Adds two related fixes: 1. Auto-complete on agent_end: When the LLM stops producing tool calls (agent_end event), mark any in_progress tasks as completed. This matches the natural semantic of 'the LLM is done for this turn, so tasks it was working on are done'. Previously, only subagent-executed tasks were auto-completed via subagents:completed. Regular tasks required an explicit TaskUpdate call, which the LLM often forgot, leaving tasks stuck in_progress. The very first agent_end of the session (fired on startup before the user sends any message) is skipped via the isFirstAgentCycle guard. 2. Fix task loss across store upgrade: In session scope, the store starts in-memory before the session ID is known, then upgrades to file-backed once upgradeStoreIfNeeded() fires. Previously, the upgrade created a brand new empty TaskStore and the old in-memory tasks were GC'd \u2014 so any task created before the first turn_start was silently lost. Now we persist the old store's tasks to the new session file (atomic temp-file + rename, same pattern as TaskStore.save()) before swapping the store reference. Without fix tintinweb#2, fix tintinweb#1 is only partially effective: agent_end fires but the in-memory task created in the same turn is in a different store instance than the file-backed one used later.
Owner
|
Thanks for the PR. going to close this one. The premise that "LLM stops producing tool calls ⇒ tasks are done" doesn't hold. |
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.
Adds two related fixes:
Auto-complete on agent_end: When the LLM stops producing tool calls (agent_end event), mark any in_progress tasks as completed. This matches the natural semantic of 'the LLM is done for this turn, so tasks it was working on are done'.
Previously, only subagent-executed tasks were auto-completed via subagents:completed. Regular tasks required an explicit TaskUpdate call, which the LLM often forgot, leaving tasks stuck in_progress.
The very first agent_end of the session (fired on startup before the user sends any message) is skipped via the isFirstAgentCycle guard.
Fix task loss across store upgrade: In session scope, the store starts in-memory before the session ID is known, then upgrades to file-backed once upgradeStoreIfNeeded() fires. Previously, the upgrade created a brand new empty TaskStore and the old in-memory tasks were GC'd \u2014 so any task created before the first turn_start was silently lost.
Now we persist the old store's tasks to the new session file (atomic temp-file + rename, same pattern as TaskStore.save()) before swapping the store reference.
Without fix #2, fix #1 is only partially effective: agent_end fires but the in-memory task created in the same turn is in a different store instance than the file-backed one used later.