Repository navigation
Conversation
aheritier
left a comment
There was a problem hiding this comment.
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.
| // 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) { |
There was a problem hiding this comment.
[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.
| }, | ||
| seed: sync.OnceValue(func() todotypes.List { | ||
| // Which of several toolsets a recorded result came from is unknown. | ||
| if len(owners) != 1 { |
There was a problem hiding this comment.
[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.
| continue | ||
| } | ||
| if todos, ok := tools.DecodeResultMeta[[]todotypes.Todo](msg.ToolResultMeta); ok { | ||
| list = todotypes.List{Todos: todos} |
There was a problem hiding this comment.
[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.
| } | ||
| 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 { |
There was a problem hiding this comment.
[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.
f14db81 to
4c27d6a
Compare
trungutt
left a comment
There was a problem hiding this comment.
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.
trungutt
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
| if lists == nil { | ||
| return bindSkillRuntime(agentTools, rt), nil | ||
| } | ||
| return bindSkillRuntime(agentTools, sessionCommandRuntime{skillRuntime: rt, ConversationLists: lists}), nil |
There was a problem hiding this comment.
[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.
There was a problem hiding this comment.
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.
| // 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) { |
There was a problem hiding this comment.
[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.
There was a problem hiding this comment.
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.
|
Please mark this PR ready for review once you’ve addressed the requested changes. Thanks! |
e3de22a to
2b8a895
Compare
aheritier
left a comment
There was a problem hiding this comment.
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-leveltodotools (pkg/runtime/commands.go:125–135). Its runtime lacksToolRunner, 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 { |
There was a problem hiding this comment.
[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.
2b8a895 to
2608875
Compare
2608875 to
64a62bb
Compare
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>
64a62bb to
7aa8306
Compare
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
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
TodoListStoreinpkg/session/todo_lists.go;TestTodoListSurvivesResume(memory and SQLite, store reopened, team reloaded)TestTodoListIsolatedPerConversationList.LastID;TestTodoTool_ConversationListContinuesIDs,TestTodoListStoreConcurrenttodoListFromHistory), and todo results are recorded in the order the lists changed;TestTodoListStartsFromHistory,TestDispatcherRecordsTodoResultsInListOrdertodotool.SidebarComponent.LoadFromSession,replayHistory;TestLoadFromSessionShowsLastTodoList,TestLoadReplaysTodoPlandeleteSessionTreeTxand the in-memoryDeleteSession;TestTodoListStoreDeletion,TestTodoListDeleteRollbackshared: true,WithStorageand stores without support keep the in-memory behaviortodoHandler.conversationLists;TestTodoTool_OwnStorageIgnoresConversationList,TestTodoListWithoutStoreSupport!list_todos(),${list_todos()}) use the conversation's list, as before this changeruntime.ResolveSessionCommand,LocalRuntime.SessionAgentTools;TestTodoListSharedWithCommandsTestTodoListSurvivesResumeandTestTodoListIsolatedPerConversationfail onmain: after the reload,update_todosontodo_1is an error andcreate_todoreturnstodo_1again, and the second conversation lists the first one's todo.Changes
pkg/sessionTodoListStoreon both stores. Migration 33 addstodo_lists; a row is owned by its root session (foreign key with cascade) and pruned with its subtree, likethink_scratchpadpkg/runtimetoolexec.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 withResolveSessionCommandbind 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'stool_input_transformhooks first,redact_secretsincluded, as the agent's calls do: the command runtime implementstools.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).toolsetOwnersandstateRootare the think helpers made generic; think's keys and error messages are unchangedpkg/runtime/toolexectool_input_transformhooks too, so a secret the script computes is scrubbed before the store keeps it (TestCodeModeTodoWritesAreRedacted). If the hooks deny it, thehook_blockedevent, theon_tool_approval_decisionhooks and thetool_response_transformhooks that rewrite the denial get the call without its arguments (TestCodeModeTodoDenialReportsNoInput)pkg/app,pkg/tui,pkg/cli,pkg/servercli.PrepareSessionUserMessagetakes the session;cli.PrepareUserMessagekeeps its signature for SDK callerspkg/toolsCapabilityTodoListspkg/tools/builtin/todomain's code. Tool output andMetakeep their shape.ConversationListsEnabledis false in the small browser build, andNewSharedbuilds a shared toolsetpkg/tuipkg/acpsession/loadreplays 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 iscmd/wasmdocs/tools/todoDesign choices open to revision
shared: truekeeps one process-wide list in memory. Its scope is what feat(todo): addshared: teamto scope a todo list to one team #4782 changes; once that settles, a shared list can be stored per conversation the same way.update_todosfail 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.todo.New()instance to several agents now gets one list per agent, as with think.WithStoragekeeps a single list.tool_result_meta) rather than from the store, so conversations recorded before this change get their panel back too.Validation
go build ./...go test ./...TestNewMemoryDatabasefails only when run as root, as onmain, and passes otherwisego test -raceonpkg/runtime,pkg/runtime/toolexec,pkg/session,pkg/cli,pkg/apptask test-wasm-js,task test-wasm-bridge(Binaryen 132)