feat(demo): Agent Theater β live, cinematic view of the real ReAct loop - #8
Merged
Merged
Conversation
Adds a fourth flagship demo surface that streams kyro's bounded ReAct agent reasoning live, against the real loop: plan (decompose) β retrieve (hybrid) β observe β β¦ β finish New: - demo/agent.py β AgentEngine drives the production konjoai.agent.react.RAGAgent unmodified. Two clearly-labelled offline seams: a rule-based DemoPlanner (no LLM) that emits valid ReAct JSON, its plan sourced from router.decompose_query; and a retrieve tool swapped to the demo PipelineEngine (real BM25 + dense + RRF) via a save/restore context manager so the global patch never leaks into the rest of the suite. - demo/agent.html β SSE-driven theater: live Thought/Action/Observation step cards, the decomposed plan + step-budget meter, real retrieved documents per retrieve step, and a typewriter answer with sources. - demo/server.py β GET /agent + SSE GET /api/agent/stream + GET /api/agent/analyze (bounded/clamped inputs); _send_sse streaming helper. - demo/pipeline.py β public hybrid() (real RRF fusion) + describe_source(). - tests/unit/test_demo_agent.py β 9 contract tests (real loop to answer, step-budget bound, step/source shape, planner JSON parses with the real react parser, and patch-containment / no test bleed). Cross-links all four surfaces: Playground Β· Observatory Β· Pipeline Β· Agent. https://claude.ai/code/session_01WWWgV1NwxaaNdPfy4PHN1K
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.
Agent Theater
A fourth flagship demo surface (
/agent) that streams kyro's real bounded ReAct loop live over SSE β the next step after the Pipeline Theater (PR #7).The reasoning loop is the production class
konjoai.agent.react.RAGAgent, run unmodified β its Thought/Action/Observation control flow, JSON action parsing, action normalization, max-step guard, tool dispatch, and step/result events all execute as-is.What's new
demo/agent.pyβAgentEnginedrives the realRAGAgent. Two clearly-labelled offline seams:DemoPlannerimplements theGeneratorprotocol and emits valid ReAct JSON; its plan is real β sub-queries fromrouter.decompose_query.RAGAgentresolveshybrid_search/rerankfrom module globals, which we swap to the demoPipelineEngine(real BM25 + dense +reciprocal_rank_fusion) for the duration of each run via a save/restore context manager β so the global patch never leaks into the rest of the suite (test_routeretc. stay green; a containment test pins this).demo/agent.htmlβ SSE-driven cinematic theater: live Thought/Action/Observation step cards, the decomposed plan + a step-budget meter, the real documents pulled on each retrieve step, and a typewriter answer with sources.demo/server.pyβGET /agent, SSEGET /api/agent/stream,GET /api/agent/analyze(bounded/clamped inputs); a_send_ssestreaming helper.demo/pipeline.pyβ publichybrid()(real RRF fusion) +describe_source().tests/unit/test_demo_agent.pyβ 9 contract tests (real loop β answer, step-budget bound, step/source shape, planner JSON parses with the realreactparser, patch-containment / no test bleed).Honesty notes
modelfield; only token generation and the storage backend are stubbed β exactly the seams a production swap isolates.Verification
pytest tests/unit/test_demo_agent.py tests/unit/test_demo_pipeline.py tests/unit/test_demo_metrics.pyβ 25 passed, stable across multiplePYTHONHASHSEEDvalues.ruff checkclean on all changed files;radon ccno function above grade C;agent.py261 lines,pipeline.py367.test_router.pystill green after a run (confirms the retrieve-tool patch is fully restored).Run it:
python3 demo/server.py # http://localhost:8766/agenthttps://claude.ai/code/session_01WWWgV1NwxaaNdPfy4PHN1K
Generated by Claude Code