Skip to content

fix(todo): keep todo lists with the conversation - #5093

Open
Sayt-0 wants to merge 13 commits into
docker:mainfrom
Sayt-0:fix/todo-lists-per-conversation
Open

Sayt-0 wants to merge 13 commits into
docker:mainfrom
Sayt-0:fix/todo-lists-per-conversation

Conversation

@Sayt-0

@Sayt-0 Sayt-0 commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #5092.

Todo lists move from the toolset instance to the session store, scoped by conversation, calling agent and toolset, as #4592 did for think scratchpads. A resumed session finds the list its agent left, conversations that share a loaded team stop sharing lists, and a reopened session shows its last list in the TUI and over ACP.

Release notes

  • Todo lists are kept with the conversation in the session store: a resumed session finds the list its agent left, conversations sharing a loaded team get separate lists, and a reopened session shows its last list in the TUI and over ACP.
  • A delegated sub-agent starts a new list for each task. Before, its list carried over from task to task, and from conversation to conversation.
  • With several todo toolsets on one agent, a stored list follows its toolset's position in the configuration: reordering the toolsets, or adding one before another, hands their lists to other toolsets.
  • A todo tool run through code mode (code_mode_tools) or from a command records no todo result: a resumed session keeps its changes, but a branch, a fork, and the TUI panel and ACP plan of a reopened session miss them.

Acceptance criteria

Criterion (#5092) Status Where
A list survives a resumed session, and a restart with the SQLite store yes TodoListStore in pkg/session/todo_lists.go; TestTodoListSurvivesResume (memory and SQLite, store reopened, team reloaded)
Conversations sharing a loaded team get separate lists yes TestTodoListIsolatedPerConversation
An ID is never handed out twice in a list yes, except in a branch or a fork of changes made through code mode or a command (documented) List.LastID; TestTodoTool_ConversationListContinuesIDs, TestTodoListStoreConcurrent
A branch, a fork, or a conversation recorded before the fix keeps the IDs its history refers to yes, except changes made through code mode or a command (documented) a list the store has never written starts from the newest list in the agent's todo results (todoListFromHistory), and todo results are recorded in the order the lists changed; TestTodoListStartsFromHistory, TestDispatcherRecordsTodoResultsInListOrder
A reopened session shows its last list (TUI panel, ACP plan) yes todotool.SidebarComponent.LoadFromSession, replayHistory; TestLoadFromSessionShowsLastTodoList, TestLoadReplaysTodoPlan
Deleting a session deletes its lists yes deleteSessionTreeTx and the in-memory DeleteSession; TestTodoListStoreDeletion, TestTodoListDeleteRollback
shared: true, WithStorage and stores without support keep the in-memory behavior yes todoHandler.conversationLists; TestTodoTool_OwnStorageIgnoresConversationList, TestTodoListWithoutStoreSupport
Commands (!list_todos(), ${list_todos()}) use the conversation's list, as before this change yes runtime.ResolveSessionCommand, LocalRuntime.SessionAgentTools; TestTodoListSharedWithCommands

TestTodoListSurvivesResume and TestTodoListIsolatedPerConversation fail on main: after the reload, update_todos on todo_1 is an error and create_todo returns todo_1 again, and the second conversation lists the first one's todo.

Changes

Area Change
pkg/session TodoListStore on both stores. Migration 33 adds todo_lists; a row is owned by its root session (foreign key with cascade) and pruned with its subtree, like think_scratchpad
pkg/runtime Each tool batch binds the caller's todo toolsets to the conversation's lists (toolexec.Dispatcher.TodoLists). The root is resolved with the call's context on the first todo call of a batch, and kept only once resolved. A list the store has never written starts from the history. Commands resolved with ResolveSessionCommand bind the current agent's todo tools to the session's lists, and store a session that no turn has stored yet when they first change a list. Their todo calls, direct or made through code mode, go through the agent's tool_input_transform hooks first, redact_secrets included, as the agent's calls do: the command runtime implements tools.ToolRunner, so code mode runs its nested calls through it too. A credential in a command's arguments, or one a script computes, is scrubbed before the store keeps it (TestCommandTodoWritesAreRedacted, TestCommandCodeModeTodoWritesAreRedacted, SQLite). toolsetOwners and stateRoot are the think helpers made generic; think's keys and error messages are unchanged
pkg/runtime/toolexec A call that uses the conversation's lists holds a batch lock until its result is recorded, so todo results are recorded in the order the lists changed. A todo call nested in code mode goes through the agent's tool_input_transform hooks too, so a secret the script computes is scrubbed before the store keeps it (TestCodeModeTodoWritesAreRedacted). If the hooks deny it, the hook_blocked event, the on_tool_approval_decision hooks and the tool_response_transform hooks that rewrite the denial get the call without its arguments (TestCodeModeTodoDenialReportsNoInput)
pkg/app, pkg/tui, pkg/cli, pkg/server The TUI (steer and follow-up included, with the session they captured), the CLI and the HTTP server's agent-switch commands resolve commands in their session. cli.PrepareSessionUserMessage takes the session; cli.PrepareUserMessage keeps its signature for SDK callers
pkg/tools CapabilityTodoLists
pkg/tools/builtin/todo Handlers read and write the conversation's list when the runtime offers one, and the toolset's storage otherwise, with main's code. Tool output and Meta keep their shape. ConversationListsEnabled is false in the small browser build, and NewShared builds a shared toolset
pkg/tui The TO-DO panel of a reloaded session shows its last successful todo result, sub-sessions included; calls are matched to their definitions by name, since definitions skip unknown tools
pkg/acp session/load replays the plan after each todo result, as a live run sends it. A plan too large to replay is sent with its entries cut to 4 KiB, and skipped if it still is
cmd/wasm The browser's shared list keeps its own storage
docs/tools/todo "Scope and Lifetime" section, including what code mode and commands leave out of the history

Design choices open to revision

  • shared: true keeps one process-wide list in memory. Its scope is what feat(todo): add shared: team to scope a todo list to one team #4782 changes; once that settles, a shared list can be stored per conversation the same way.
  • A delegated sub-agent starts a new list for each task, as think does. Before, a sub-agent's list carried over from task to task, and from conversation to conversation.
  • Unlike think's scratchpad, a list the store has never written (a branch, a fork, an import, a conversation recorded before this change) starts from the newest list in the agent's todo results: the one with the highest todo number, the last recorded among equal ones. The model refers to todos by ID, and its history holds those IDs; an empty list would make update_todos fail on them and hand them out again. This needs a single todo toolset on the agent, shared ones included, since a recorded result does not say which toolset it came from. In a transcript recorded before this change, two status updates made by parallel calls of one batch cannot be ordered, so one todo may start with its earlier status.
  • The small browser build keeps each list in its toolset, as before: a browser session builds its own toolsets, so their lists are already its own, and the build stays about 50 KiB smaller.
  • A command typed before the first turn stores the session when it first changes a todo list, since a stored root session owns the lists. A todo tool run through code mode or from a command records no todo result, so a branch or a fork made after it starts without its changes, and may hand out one of its IDs again; "Scope and Lifetime" documents it. Seeding a branch or a fork from its parent's stored list would close the gap, and can follow.
  • A Go embedder that passes one todo.New() instance to several agents now gets one list per agent, as with think. WithStorage keeps a single list.
  • The TUI and ACP restore from the history (the last tool_result_meta) rather than from the store, so conversations recorded before this change get their panel back too.
  • Resolving the root loads the stored session, as it does for think. A lookup of the session's parent and origin alone would make both cheaper.

Validation

Check Result
go build ./... pass
go test ./... 276 packages pass; TestNewMemoryDatabase fails only when run as root, as on main, and passes otherwise
go test -race on pkg/runtime, pkg/runtime/toolexec, pkg/session, pkg/cli, pkg/app pass
golangci-lint v2.14.0 0 issues
Project cops, go.mod tidiness, TypeScript SDK generation pass, nothing to regenerate
task test-wasm-js, task test-wasm-bridge (Binaryen 132) pass, small build within the 32 MiB budget

@Sayt-0
Sayt-0 requested a review from a team as a code owner December 2, 2026 11:24
Copilot AI balanced review requested due to automatic review settings December 2, 2026 11:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@aheritier aheritier added area/docs Documentation changes area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection area/sessions For features/issues/fixes related to session lifecycle (resume, persistence, export) area/tools For features/issues/fixes related to the usage of built-in and MCP tools area/tui For features/issues/fixes related to the TUI kind/fix PR fixes a bug (maps to fix:). Use on PRs only. labels Dec 2, 2026

@aheritier aheritier left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Five blockers: command compatibility, two history-seeding bugs, ACP session loading, and the small WASM size budget.\n\n[blocking] The small browser build exceeds its 32 MiB budget. The PR's cross-compile log records 32.05 MiB at the assertion in cmd/wasm/node/small_test.js:26; the same test on the exact base passes. Keep the optimized artifact within 32 MiB with task test-wasm-bridge.

Comment thread pkg/tools/builtin/todo/todo.go Outdated
// list returns the conversation's list when the runtime keeps one, and the
// toolset's own storage otherwise.
func (h *todoHandler) list(rt tools.Runtime) todoList {
if !h.ownStorage && rt != nil && rt.Supports(tools.CapabilityTodoLists) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[blocking] Existing slash commands now read and write a different list from the agent. pkg/runtime/commands.go:345 calls the handler with NopRuntime, so after the agent creates a todo, a configured !list_todos() still returns an empty list; conversely, a command-created ID cannot be updated by the agent. Both paths used the same list before this change. Bind command expansion to the active conversation's list when there is one, and add a regression test that creates a todo through one path and reads or updates it through the other.

Comment thread pkg/runtime/tool_dispatch.go Outdated
},
seed: sync.OnceValue(func() todotypes.List {
// Which of several toolsets a recorded result came from is unknown.
if len(owners) != 1 {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[blocking] This ambiguity check counts only conversation-backed toolsets, but history can contain results from shared toolsets too. With two filtered todo entries for one agent (one shared, one private), a shared call can write the last historical result; the first private call then seeds from it because len(owners) is 1. The private list starts with the shared list's items and IDs. Count all todo toolsets when deciding whether history is unambiguous, or record the result's owner and match it explicitly. Please cover one shared plus one private toolset in the history-seeding test.

Comment thread pkg/runtime/tool_dispatch.go Outdated
continue
}
if todos, ok := tools.DecodeResultMeta[[]todotypes.Todo](msg.ToolResultMeta); ok {
list = todotypes.List{Todos: todos}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[blocking] Transcript order is not commit order. The dispatcher runs calls in parallel (pkg/runtime/toolexec/dispatcher.go:370) and runs response transforms before recording them (:1384–1395). If a batch creates todo_1 and todo_2 and the first call's transform finishes last, the transcript ends with the earlier snapshot containing only todo_1. A fork containing both results then loses todo_2 and hands out its ID again. Preserve mutation order in the recorded snapshots or otherwise reconstruct the newest state without lowering the ID high-water mark. Add a fork test where the two committed snapshots are recorded in reverse order.

Comment thread pkg/acp/replay.go Outdated
}
if state != nil && isTodoTool(state.definition.Name) && msg.Message.ToolResultMeta != nil {
if plan := buildPlanUpdateFromTodos(msg.Message.ToolResultMeta); plan != nil {
if err := a.sendReplayUpdate(ctx, s.id, *plan); err != nil {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[blocking] A large historical todo list can now prevent the entire session from opening. Replay truncates the tool's text at line 166, but this plan sends every description from ToolResultMeta in one notification. If it exceeds maxReplayUpdateBytes, sendReplayUpdate returns an error and replayLoadedSession closes the session. Bound the plan or skip an oversized plan without aborting transcript replay. Add a LoadSession test with oversized todo metadata that still loads successfully.

@aheritier
aheritier marked this pull request as draft December 3, 2026 10:28
@Sayt-0
Sayt-0 force-pushed the fix/todo-lists-per-conversation branch from f14db81 to 4c27d6a Compare December 4, 2026 06:32
Copilot AI balanced review requested due to automatic review settings December 4, 2026 06:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@Sayt-0
Sayt-0 marked this pull request as ready for review December 4, 2026 06:33

@trungutt trungutt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, solid work. All five earlier blockers are fixed and tested. Build, race tests and lint pass locally.

Before merging

  • CI hasn't run on this push. Locally the small WASM build is ~2.5 KB over main, which leaves very little of the 32 MiB budget. Please confirm in CI.

Code-mode gap
With code_mode_tools / --code-mode-tools, todo calls run nested via RunTool and record no todo result in history. Resume works (store), but:

  • branch/fork starts with an empty list, so IDs the model knows go missing and can be reused
  • reloaded session shows an empty TO-DO panel and no ACP plan

!create_todo() commands have the same gap. Please either document it in "Scope and Lifetime", or seed forks from the parent's stored list.

Release notes

  • Sub-agents get a fresh list per task.
  • Lists follow toolset position in config.

Approving once CI is green and the code-mode gap is documented or fixed.

Copilot AI balanced review requested due to automatic review settings December 4, 2026 07:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

trungutt
trungutt previously approved these changes Dec 4, 2026

@trungutt trungutt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks. The code-mode and command gap is now documented, and CI is green, including the small WASM size budget. LGTM.

Nit: "may hand out again an ID" → "may hand out an ID again".

@aheritier aheritier left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Two blockers: slash-command todo writes can persist unredacted credentials, and the new PrepareUserMessage signature breaks existing Go SDK callers.

Prior threads: Maintainer review #6186270970 accepted the documented history limitation for code-mode and command-generated todos.

Comment thread pkg/runtime/commands.go Outdated
if lists == nil {
return bindSkillRuntime(agentTools, rt), nil
}
return bindSkillRuntime(agentTools, sessionCommandRuntime{skillRuntime: rt, ConversationLists: lists}), nil

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[blocking] This gives slash-command handlers a persistent todo list without the input redaction that normal tool calls get. A command that passes a credential from its arguments into create_todo calls the handler directly (pkg/js/expand.go:199 or pkg/runtime/commands.go:403), bypassing the transform at pkg/runtime/toolexec/dispatcher.go:637. The description is then written verbatim to SQLite (pkg/session/todo_lists.go:159–165), even if the command does not include the tool output in the prompt. Apply the agent's redaction policy before these writes and add a SQLite regression test using a synthetic credential.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 5af9618 for the todo calls a command makes, and in e8f0e09 for the ones code mode makes when a command runs run_tools_with_javascript.

The command runtime now implements ToolRunner. Every tool a command runs, directly or through code mode, goes through its RunTool, which runs the agent's tool_input_transform hooks on a todo call before the handler writes to the store, redact_secrets included (on by default). A hook that rejects the call returns a tool error, as for the agent. Other tools a command runs are unchanged: they store nothing new, and a command that passes a credential to a shell tool on purpose keeps working.

TestCommandTodoWritesAreRedacted covers !create_todo(...) and ${create_todo(...)}, and TestCommandCodeModeTodoWritesAreRedacted a command whose script joins a synthetic dckr_pat_ token at run time. Both read todo_lists back from a SQLite store; without the fixes, the token is stored verbatim.

Comment thread pkg/cli/runner.go Outdated
// pass the attachment path to session.Session.AddAttachedFile so sub-agents
// inherit the file context.
func PrepareUserMessage(ctx context.Context, rt runtime.Runtime, userInput, globalAttachPath string) (*session.Message, string, error) {
func PrepareUserMessage(ctx context.Context, rt runtime.Runtime, sess *session.Session, userInput, globalAttachPath string) (*session.Message, string, error) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[blocking] The Go SDK guide explicitly directs embedders to call cli.PrepareUserMessage (docs/guides/go-sdk/index.md:590). Adding a required positional argument makes every existing four-argument call fail to compile. Keep the original signature as a wrapper and use a separate session-aware entry point for callers that have a session.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 7d78898. cli.PrepareUserMessage keeps its four-argument signature and resolves commands without a session, as before. cli.PrepareSessionUserMessage is the session-aware entry point, used by cli.Run and the TUI's first message. The existing tests call the original signature again.

@aheritier
aheritier marked this pull request as draft December 4, 2026 12:44
@aheritier

Copy link
Copy Markdown
Collaborator

Please mark this PR ready for review once you’ve addressed the requested changes. Thanks!

@Sayt-0
Sayt-0 force-pushed the fix/todo-lists-per-conversation branch from e3de22a to 2b8a895 Compare December 4, 2026 13:07
Copilot AI balanced review requested due to automatic review settings December 4, 2026 13:07
@Sayt-0
Sayt-0 marked this pull request as ready for review December 4, 2026 13:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@aheritier aheritier left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Two redaction blockers: one inline and one still open below.

Prior threads:

  • #4799755937 remains open for slash commands that invoke run_tools_with_javascript. The command wrapper only transforms top-level todo tools (pkg/runtime/commands.go:125–135). Its runtime lacks ToolRunner, so Code Mode calls the nested todo handler directly (pkg/tools/codemode/exec.go:243–246) with conversation storage still enabled. That can write an unredacted description to SQLite. Apply the input policy to nested todos in command expansion too, and add a SQLite regression test for that route.
  • Maintainer review #6186270970 accepted the documented history limitation for todos created through commands or Code Mode.

// The session store keeps what a todo call writes: transform its input as
// the agent's, so redact_secrets scrubs a value the script computed.
if tool.Category == "todo" {
if _, blocked := c.transformToolInput(ctx); blocked {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[blocking] A denied nested todo can expose the credential that this transform is meant to scrub. transformToolInput handles a denial before applying ModifiedInput (pkg/runtime/toolexec/tool_hooks.go:27–32), so blockToolHook emits a HookBlockedEvent with the original arguments (:154). serve api serializes that event to SSE (pkg/server/server.go:553–557). Keep the denial, but omit or scrub its arguments before publishing the event or notifying approval hooks. Add a regression test that rejects a nested todo containing a synthetic credential and checks that the credential never reaches those consumers.

@Sayt-0 Sayt-0 Dec 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 2608875.

@aheritier
aheritier marked this pull request as draft December 4, 2026 15:12
@Sayt-0
Sayt-0 force-pushed the fix/todo-lists-per-conversation branch from 2b8a895 to 2608875 Compare December 4, 2026 17:54
Copilot AI balanced review requested due to automatic review settings December 4, 2026 17:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@Sayt-0
Sayt-0 force-pushed the fix/todo-lists-per-conversation branch from 2608875 to 64a62bb Compare December 5, 2026 10:04
Copilot AI balanced review requested due to automatic review settings December 5, 2026 10:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@Sayt-0
Sayt-0 marked this pull request as ready for review December 5, 2026 10:05
Sayt-0 added 13 commits December 6, 2026 14:15
The todo toolset kept its list in the toolset instance. A session resumed
in a new process found an empty list while the model still saw the old one
in its history, so update_todos failed on the earlier IDs and create_todos
started again at todo_1. Conversations that reuse one loaded team (serve
mcp, serve a2a) shared each agent's list.

Store the lists in the session store, keyed by conversation, calling agent
and toolset and owned by the root session, as think scratchpads are. The
runtime hands them to the toolset through its tools.Runtime handle and
resolves the root on the first todo call of a batch only. A list the store
has never written starts from the last list the agent's history shows, so
branches, forks and conversations recorded before this change keep the IDs
they refer to. Shared and WithStorage toolsets, and hosts whose store
cannot keep lists, keep the in-memory storage.

Signed-off-by: Sayt-0 <louis.dal-moro-compta@epita.fr>
The TO-DO panel only followed live tool results, and ACP session/load
replayed the tool calls without the plan. Both now show the last list the
session's todo results recorded, sub-sessions included.

Signed-off-by: Sayt-0 <louis.dal-moro-compta@epita.fr>
With conversation lists linked in, the small WASM profile went 52 KB
over its 32 MiB budget, against 3 KB of headroom on main. Leave them out
of that profile, as it leaves out other features: ConversationListsEnabled
is false under docker_agent_wasm_small, so the linker drops the runtime's
list binding, the store's list methods and the toolsets' conversation
path. A browser session builds its own toolsets, so their lists are its
own there.

The toolsets' own storage path is main's code again, and NewShared marks
a shared toolset without linking WithStorage.

Signed-off-by: Sayt-0 <louis.dal-moro-compta@epita.fr>
The !tool() and ${tool()} calls of a command ran with NopRuntime, so a
todo tool read and wrote the toolset's own list, which the agent no
longer uses: !list_todos() showed nothing the agent created, and the
agent could not update a todo a command created.

ResolveSessionCommand binds them to the session the command is typed in,
through LocalRuntime.SessionAgentTools, and the TUI, the CLI and the
HTTP server pass their session. A command that comes before the first
turn stores the session, since a stored root session owns the lists.

Signed-off-by: Sayt-0 <louis.dal-moro-compta@epita.fr>
A recorded todo result says which agent made it, not which toolset. The
check counted only the toolsets kept with the conversation, so beside a
shared toolset a private list could start from the shared list's result.
Count every todo toolset, and key each by its position among all of them.

Signed-off-by: Sayt-0 <louis.dal-moro-compta@epita.fr>
A batch runs its calls in parallel and transforms their results before
recording them, so a list changed later could be recorded first. A fork
then started from the older list, lost a todo and handed its ID out again.

A call that uses the conversation's lists now holds a batch lock from
that first use until the dispatcher is done with it, so results are
recorded in the order the lists changed. For transcripts recorded before,
the seed takes the list with the highest todo number, the last recorded
among equal ones: IDs only grow, so that list is the newest.

Signed-off-by: Sayt-0 <louis.dal-moro-compta@epita.fr>
Replay sends a plan after each todo result, and a plan over the replay
size limit failed the load, which closed the session. Skip such a plan:
it is display only, and the rest of the transcript still replays.

Signed-off-by: Sayt-0 <louis.dal-moro-compta@epita.fr>
A todo tool run through code mode or from a command changes the stored
list but records no todo result. Branches and forks seed their list from
the history, and so do the TUI panel and the ACP plan of a reopened
session, so they miss those changes, and a branch or a fork may hand out
an ID again.

Signed-off-by: Sayt-0 <louis.dal-moro-compta@epita.fr>
The todo tools a command runs write to the conversation's stored list,
but a command calls their handlers directly, without the
tool_input_transform hooks the dispatcher runs on the agent's calls. A
credential passed in a command's arguments was written to the session
store verbatim, even with redact_secrets on.

A command's todo calls now go through the agent's tool_input_transform
hooks first, redact_secrets included, and a hook that rejects a call
turns it into a tool error, as for the agent. Other tools a command runs
are unchanged.

Signed-off-by: Sayt-0 <louis.dal-moro-compta@epita.fr>
The Go SDK guide points embedders to cli.PrepareUserMessage, and adding
a session parameter to it broke every existing call. It keeps its
signature and resolves commands without a session, as before.
PrepareSessionUserMessage takes the session the input is for, so that
the tools a command runs share its todo lists; the CLI and the TUI's
first message use it.

Signed-off-by: Sayt-0 <louis.dal-moro-compta@epita.fr>
Code mode runs a nested todo call's handler directly, without the
tool_input_transform hooks the dispatcher runs on the agent's calls.
The transform of the script's own arguments catches a secret written in
the script, but not one the script computes, such as a token joined
from two strings or read through another tool, and the session store
kept it verbatim.

A nested todo call now goes through the agent's tool_input_transform
hooks first, redact_secrets included, and a hook that rejects it turns
it into a tool error. Other nested calls are unchanged.

Signed-off-by: Sayt-0 <louis.dal-moro-compta@epita.fr>
A command that runs run_tools_with_javascript reached the nested todo
handlers directly: the command runtime did not implement ToolRunner, so
code mode called them without the agent's tool_input_transform hooks,
and redact_secrets left a credential the script computed in the session
store.

The command runtime now implements ToolRunner, and every tool a command
runs, directly or through code mode, goes through its RunTool, which
transforms todo calls first. TestCommandCodeModeTodoWritesAreRedacted
covers the route with a SQLite store.

Signed-off-by: Sayt-0 <louis.dal-moro-compta@epita.fr>
A todo call nested in code mode goes through the tool_input_transform
hooks before any event carries its input. When a hook denied it, the
hook_blocked event, the on_tool_approval_decision hooks and the
tool_response_transform hooks that rewrite the denial still got its
original arguments, and serve api streams that event over SSE, so a
credential the script computed could leak there.

A denied nested todo call is now reported with its arguments left out.
TestCodeModeTodoDenialReportsNoInput denies one that holds a synthetic
token, and checks that neither the events nor these hooks see it.

Signed-off-by: Sayt-0 <louis.dal-moro-compta@epita.fr>
Copilot AI balanced review requested due to automatic review settings December 6, 2026 14:39
@Sayt-0
Sayt-0 force-pushed the fix/todo-lists-per-conversation branch from 64a62bb to 7aa8306 Compare December 6, 2026 14:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs Documentation changes area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection area/sessions For features/issues/fixes related to session lifecycle (resume, persistence, export) area/tools For features/issues/fixes related to the usage of built-in and MCP tools area/tui For features/issues/fixes related to the TUI kind/fix PR fixes a bug (maps to fix:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Todo lists are lost when a session is resumed

4 participants