0026: Typed AI tools, a bounded agent and debugger assistance
- Status: Proposed (implemented in Phase 2, task 019)
- Date: 2026-12-06
Context
Tasks 017 and 018 assemble and validate tool calls but never run them, and debugger state had no way to be allowed. An agent needs to read code, propose changes and run builds and tests, without gaining any power the user did not give it, without running in the background, and without trusting model output.
Decision
- A versioned tool registry in
ide-ai(axiom.read_range@1, …). Each tool keeps four parts apart: the description and schema the model sees; strict validation into a typed input (unknown fields, oversized arguments and unsafe paths refused); authorization by access kind (read, debugger, propose, execute); and execution by the host through theToolHosttrait. Provider wire names are derived (axiom__read_range__v1). - The core is the host (
ide_core::ai_tools): reads go through the AI file context (canonical path, no link escape, ignored and secret files refused), locations through the language client under a tool purpose that never moves the caret, proposals throughproposal_from_planand the shared review, and tasks through the task runner. Sharing is checked when a call starts and when its output returns. - No dangerous tools exist. No shell, arbitrary command, arguments or environment, version control, publishing, installs, settings or debugger control.
run_tasktakes only a configured build, check or test task id. The user approves anExecutionPlan(command, folder, environment variable names) bound to a fingerprint of the whole configuration and the permission epoch; it is re-checked when the task starts. - The agent is a finite state machine (
ide_ai::agent) driven by the host's poll: plan → approval → model turns with tools → results → finish. One request and one tool call at a time. The plan request carries no workspace content. Approval creates anAgentRungrant for the run's folder, epoch, provider and model; ending the run revokes it. - Hard limits (steps, tool calls, tokens, request size, tool output, files, wall clock, cost when calculable) are set by the user's side only. Unknown cost needs explicit consent; tokens are still bounded by estimates.
- Debugger sharing has its own grant (
ShareDebuggerState), from a dialog naming every destination. The snapshot separates observed values (with the suspend generation) from Axiom's deterministic prediction, and its revision covers suspend, thread and frame, so a resume or frame change makes it stale. Debugger fixes are ordinary edit proposals.
Alternatives considered
- Model-driven loop on a background thread. Simpler, but it would act without the UI running and complicate cancellation; the poll-driven machine stops exactly when the user stops it.
- Running tasks from free-form commands. Rejected: the model would choose argv and environment. Task ids bind execution to what the user configured and trusts.
- A standing "run tools" grant. Rejected: each task run is approved, and proposals always go through review.
- Parallel tool calls. Faster, but harder to audit and cancel; one at a time keeps the activity log and limits exact.
Consequences
- Language providers do not contribute tools yet; the registry and permissions are the place they will plug in.
- Definitions and references need the file open in the editor (the language server's view).
- Limits are fixed defaults in this version, shown in the panel.
Validation
ide-ai agent tests with a scripted model and fake host (full flow, injection and malicious arguments, unknown tools, unknown cost, revocation, epoch change, iteration, tool-call, token, time, file and cost limits, stop while streaming, debugger grant and staleness) and tool registry unit tests; ide-core ai_tools tests (canonical reads, ignored files and links, proposals only for read files, task approval bound to configuration and trust with a real child process, a full agent run with review and a real test result), the semantic tool-locations test, and the debugger snapshot test with the fake adapter; desktop UI tests for the agent panel and the debugger permission.