docs(examples): codebase-qa demo — watch the governor kill a runaway agent - #31
Merged
Conversation
A self-contained, runnable demo (Python SDK + proxy) that shows RiskKernel's headline feature end to end: a real ReAct loop over a codebase that the deterministic governor halts on its loop/dollar budget — the kill comes from the daemon (HTTP 402), not the script. - examples/codebase-qa/agent.py: --mode normal (finishes within budget) and --mode runaway (loops until the governor halts it); routes every model call through run.proxy_config() so the proxy meters cost and enforces the budget; stdlib-only (urllib) beyond the RiskKernel SDK. No RAG, vector DB, or framework. - examples/codebase-qa/sample/: a tiny todo app used as the target codebase. - examples/codebase-qa/README.md: 60-second run for both modes + expected output. - README + CHANGELOG: link the example.
Ran both modes against a real model and replaced the placeholder output with the actual runs. The halt summary now reports the authoritative signal — the gateway's 402 loop_budget_exceeded surfaced as BudgetExceeded — and the governor's own ledger (loops vs budget, cost vs budget), rather than the run's persisted status field, which lags for loop/time-budget halts (see #34). The deterministic kill is unchanged; only the demo's reporting is made precise.
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
examples/codebase-qa/, a self-contained, runnable demo that shows the headline feature end to end: deterministic budget/loop governance halting a runaway agent, with a real model.What it is
A plain ReAct-style codebase Q&A agent (no RAG, no vector DB, no framework) built on the Python SDK. Every model call is routed through
run.proxy_config(), so the proxy meters tokens/cost and the governor enforces the per-run loop / dollar / time budget around the loop. The kill comes from the daemon (HTTP402), surfaced asBudgetExceeded— never faked in the script.Two modes:
--mode normal— a sensible question that completes within budget; prints each step, tokens, and running USD cost, then the answer.--mode runaway— the same agent with a deliberately weak stopping condition (told to re-read every file), so it loops. Counters climb, then the loop budget halts it cleanly.Layout
Dependencies
None beyond the RiskKernel Python SDK and an LLM provider key (BYO
ANTHROPIC_API_KEYon the daemon). The proxy call uses stdliburllib.Notes
governed_tool/run.approvefor the side-effecting case.[Unreleased]).