Skip to content

Conversation

@tlongwell-block
Copy link
Collaborator

@tlongwell-block tlongwell-block commented Aug 18, 2025

Overview

Refactors the TODO tool functionality from agent-scoped (shared across all sessions) to session-scoped (isolated per session). This change provides better data isolation, persistence, and user experience by ensuring each session maintains its own independent TODO list.

Key Changes

Architecture

  • Removed agent-level TODO storage (Arc<Mutex<String>> from Agent struct)
  • Added session-level TODO storage (todo_content: Option<String> in SessionMetadata)
  • Implemented session-aware TODO tool dispatch methods with proper error handling

Session Storage

  • Enhanced SessionMetadata with todo_content field
  • Added backward-compatible deserializer for existing sessions
  • TODO content now persists with session data in .jsonl files

Tool Behavior

  • TODO read/write operations now require active session context
  • Character limits still enforced via GOOSE_TODO_MAX_CHARS environment variable
  • Graceful error handling when no session context is available

Benefits

🔒 Data Isolation

Each session maintains its own TODO list, preventing cross-contamination between different conversations or users.

💾 Persistence

TODO lists survive agent restarts and are automatically saved/restored with session data.

🔄 Backward Compatibility

Existing sessions without TODO content continue to work seamlessly with empty TODO lists.

🧪 Robust Testing

Comprehensive integration test suite covering persistence, isolation, concurrency, and edge cases.

Breaking Changes

  • TODO tools now require session context and will error if called without it
  • Agent-scoped TODO data is not migrated (sessions start with empty TODO lists)

Files Changed

  • crates/goose/src/agents/agent.rs - Core TODO dispatch logic
  • crates/goose/src/session/storage.rs - Session metadata enhancement
  • crates/goose/tests/todo_session_integration.rs - New integration tests
  • crates/goose/tests/todo_tools_test.rs - Removed (agent-scoped tests)
  • Various test files updated for new metadata structure

Testing

  • ✅ Session isolation and persistence
  • ✅ Character limit enforcement
  • ✅ Special character handling
  • ✅ Concurrent access scenarios
  • ✅ Backward compatibility
  • ✅ Error handling edge cases

This change significantly improves the user experience by providing persistent, isolated TODO lists that follow session boundaries rather than being shared across the entire agent lifecycle.

@tlongwell-block tlongwell-block marked this pull request as ready for review August 18, 2025 17:11
@tlongwell-block tlongwell-block changed the title Session scoped todo Move To-Do Tool to Session Scope from Agent Scope Aug 18, 2025
Copy link
Collaborator

@katzdave katzdave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, did some testing! Love that now I can pick up my todo list when resuming a session, can we just reduce the branching.

One other thing I noticed is the TODO: READ tool doesn't return any data, which provides a poor experience when resuming a session. Is that an easy fix? If not can follow up with that later.

Also when you pull in main again, make sure to flip it back on, #4158 disabled it.

Copy link
Collaborator

@katzdave katzdave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job! Excited to have this back.

// Add task planner tools
// TODO: Re-enable after next release
// prefixed_tools.extend([todo_read_tool(), todo_write_tool()]);
prefixed_tools.extend([todo_read_tool(), todo_write_tool()]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

accumulated_input_tokens: Option<i32>,
accumulated_output_tokens: Option<i32>,
working_dir: Option<PathBuf>,
todo_content: Option<String>, // For backward compatibility
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming this lets us load old sessions from before this feature?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!

@tlongwell-block tlongwell-block requested a review from a team as a code owner August 21, 2025 16:22
@github-actions
Copy link
Contributor

PR Preview Action v1.6.0

🚀 View preview at
https://block.github.io/goose/pr-preview/pr-4157/

Built to branch gh-pages at 2025-08-21 16:24 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Copy link
Contributor

@dianed-square dianed-square left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tlongwell-block -- this appears to be overwriting recent /documentation changes that were merged into main

@tlongwell-block tlongwell-block force-pushed the session_scoped_todo branch 2 times, most recently from b0bec9b to 31a20e6 Compare August 21, 2025 17:51
@tlongwell-block
Copy link
Collaborator Author

Oh boy. Goose borked this branch something fierce. I'll patch it up. Just a minute

@michaelneale
Copy link
Collaborator

michaelneale commented Aug 22, 2025

lending my 👍 my support to this, as I really think we are missing out on this (I think that failure needs to run a just command to update the spec)

@tlongwell-block tlongwell-block merged commit b16741d into main Aug 22, 2025
11 checks passed
@tlongwell-block tlongwell-block deleted the session_scoped_todo branch August 22, 2025 14:53
michaelneale added a commit that referenced this pull request Aug 24, 2025
* main:
  docs: Plan tutorial (#4309)
  Extensions Modal Improvements (#4293)
  docs: fixed cicd tutorial pipeline in docs (#4223)
  Read oltp config from config and env (#4292)
  release/1.6.0 (#4280)
  docs: fix broken links in Docker tutorial (#4285)
  Remove half-second wait, rework auto submit (#4282)
  Block send until extensions are ready (#4271)
  fix: improve OpenAI-compatible error handling and add test coverage (#4175)
  Move To-Do Tool to Session Scope from Agent Scope (#4157)
  fix: recipe params not being replaced all the time (#4207)
  chore: removing little-used session sharing feature (#4249)
  Stop auto scrolling when agent responds and let scroll area handle scrolling to bottom (#4257)
  restore cli projects from accidental removal during cleanup (#4266)
  Fix: deep link extension installation to show dialog for headers configuration (#4150)
michaelneale added a commit that referenced this pull request Aug 25, 2025
* main: (24 commits)
  feat: autovisualiser of structured data with mcp-ui (#4153)
  docs: Plan tutorial (#4309)
  Extensions Modal Improvements (#4293)
  docs: fixed cicd tutorial pipeline in docs (#4223)
  Read oltp config from config and env (#4292)
  release/1.6.0 (#4280)
  docs: fix broken links in Docker tutorial (#4285)
  Remove half-second wait, rework auto submit (#4282)
  Block send until extensions are ready (#4271)
  fix: improve OpenAI-compatible error handling and add test coverage (#4175)
  Move To-Do Tool to Session Scope from Agent Scope (#4157)
  fix: recipe params not being replaced all the time (#4207)
  chore: removing little-used session sharing feature (#4249)
  Stop auto scrolling when agent responds and let scroll area handle scrolling to bottom (#4257)
  restore cli projects from accidental removal during cleanup (#4266)
  Fix: deep link extension installation to show dialog for headers configuration (#4150)
  feat: Add message queue system with interruption handling (#4179)
  Start extensions concurrently  (#4234)
  Add X-Title and referer headers on exchange to tetrate (#4250)
  docs: update View/Edit Recipe menu item name (#4267)
  ...
shellz-n-stuff pushed a commit to shellz-n-stuff/goose that referenced this pull request Aug 27, 2025
dorien-koelemeijer pushed a commit to dorien-koelemeijer/goose that referenced this pull request Sep 2, 2025
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.

6 participants