Repository navigation
add_add_stored_queries and app_remove_stored_queries tools - #43
Merged
Merged
Conversation
New app_add_stored_queries and app_remove_stored_queries agent tools manage which stored queries an existing app may call. Read-only queries are granted immediately; write queries require user approval through context.ask_user(), showing the SQL for each one. Removing access never prompts. app_create now validates stored_queries the same way the web form does (query must exist and the actor needs view-query) and asks for approval before creating an app that is granted write queries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016BvfqAShzDp3cKzTBJtGfa
Resolves the agent_tools.py conflict by keeping both the stored query grant helpers from this branch and the AppEditToolset/_render_app changes from main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 agent tools for managing which stored queries an existing app may call. Write queries need the user's approval first.
Claude Opus 5.5
New tools
app_add_stored_queries(app_id, stored_queries)edit-app. Eachdatabase/querymust exist and the actor needsview-queryon it, the same check the web form makes (_selected_stored_queries).context.ask_user()approval for the whole call. It shows the app name, a warning that the app runs these queries with the viewer's permissions, and the SQL for each write query.{"cancelled": true, ...}with "do not retry unless they ask you to".ask_userisn't available (QuestionsNotSupported, matched by class name so datasette-agent stays optional), write grants return an error pointing the user to the app's edit page.Registry.set_stored_queries, so each one is recorded as an app revision.app_remove_stored_queries(app_id, stored_queries)removes access and never prompts.Changes to
app_createstored_queriesis now validated as above. Before, the agent path saved whatever strings it was given.Tests
New
tests/test_stored_query_agent_tools.pycovers:app_createpathsToolContext: the first call raisesQuestionPending, and once the question is answered the re-run saves the granttests/test_debug_jobs.py::test_frame_serves_job_revision_with_debug_bridgefails onmaintoo. It expects ano-storecache header but getsprivate, no-store. This PR doesn't touch it.Not in this PR
app_createstill doesn't validatesql_databases.sql_databasesorcsp_originsdoesn't ask for approval.Generated by Claude Code