Repository navigation
Conversation
Tools that declare a context parameter receive a per-invocation
ToolContext. await context.ask_user(...) asks the user a boolean,
multiple-choice or free-text question. With no stored answer the turn
suspends: the question persists to the new agent_questions table, an
SSE question event renders a form in the chat UI, and the chain stops
before the next model call. Answering (POST
/-/agent/{cid}/question/{qid}) re-executes the pending tool calls -
answered questions replay from the database - then continues the
chain. State is fully database-backed, so suspended conversations
survive server restarts; the form re-renders on page load.
Replay is keyed on (conversation_id, call_key, ask_index) where
call_key uses the provider tool_call_id (via the llm library's new
llm_tool_call parameter, now an editable dependency) with a
tool-name+arguments-hash fallback. Background agents and CLI chat
raise QuestionsNotSupported instead of suspending.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
New built-in save_query tool stores SQL the agent has written as a Datasette stored query (read-only or write - detected by Datasette's analyzer). Validation and persistence go through Datasette's own /-/queries/analyze and /-/queries/store JSON endpoints, called via datasette.client as the requesting actor, so name rules, duplicate detection, is_write analysis and write-permission enforcement stay in sync with the query creation web UI. Invalid SQL, permission problems and name collisions go straight back to the model; everything else requires explicit human approval before anything is stored. That approval uses the new ask_user(html=) parameter: trusted HTML (here the escaped SQL plus name/database/type/visibility details) rendered above the question in the chat UI. The html rides along in the agent_questions row (with a migration for existing tables), the SSE question event and the page-load JSON. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
QuestionPending now subclasses llm.PauseChain, so suspension is a single except clause around the chain loop: llm guarantees sibling tool calls complete (their results arrive via after_call as usual), no provider call is made with a placeholder result, and the paused call gets no tool_result row - which is exactly what makes the llm chain re-execute it on resume. resume_agent() collapses to 'run the chain again': llm detects the persisted history ending in unresolved tool calls and re-executes them through the normal before_call/after_call machinery, so resumed calls now emit the same SSE events as live ones. Deletes the manual resume runner and find_pending_tool_calls() (~110 lines), the suspension flag, and the after_call exception sniffing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
All four llm features ask_user() relies on (llm_tool_call parameter, guaranteed tool_call_ids, PauseChain, chain resume from unresolved tool calls) shipped in 0.32a3. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
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.

Also resulted in a number of LLM improvements, now shipped in 0.32a3: