MCP Tool Backend for Interactive Mode - #110
Open
bimu233 wants to merge 11 commits into
Open
Conversation
…unavailable tools over and over again
Snapshot of our browser-UI work and local debug fixes before merging the more comprehensive bug fixes from PR ChicagoHAI#104.
Adopt ChicagoHAI#104's more comprehensive fixes (arg quoting, host->container path translation, in_progress idea-file fallback, manager_session.json array serialization, agent_runner workspace check, system-prompt tool discipline) and drop our local equivalents. Keep our additions: the browser UI (channel.py, web_server.py, visualizer/), manager web-channel wiring, and the src/ mount. system_prompt.txt keeps both ChicagoHAI#104's tool rules and our engagement-tuning.
Build a 3-pane browser UI on top of interactive mode (ChicagoHAI#86) and its bug fixes (ChicagoHAI#104): - dashboard strip (phase derived from live agent activity, cost, agents, papers, files, elapsed) - conversation pane: clean prose (strips tool-call XML/meta-chatter), question vs. info styling, 'manager is thinking' indicator, queued-message UX - live activity log: collapsible rows, friendly tool names, expandable system/result rows, and quote-to-chat ('ask about this') - fixed branding images (logo + manager avatar), served read-only See INTERACTIVE_WEB_CHANGES.md for the full breakdown.
…dd reviewer notes)
This was referenced Jun 9, 2026
jingxuangu
pushed a commit
to jingxuangu/NeuriCo
that referenced
this pull request
Jun 9, 2026
… prompt, IPC, annotations) A review pass over the diff (incl. the embraced ChicagoHAI#110 backend) surfaced a cluster of bugs — fixed here. Most MCP issues are inherited from ChicagoHAI#110; the annotation ones are ours. HIGH: - MCP stale world model: tools run in the MCP subprocess, so the manager's per-turn digest never saw its own updates. ResearchState.reload() (in place) is now called each turn in _agent_step. (This one is ours — the seam between the in-process world model and ChicagoHAI#110's subprocess execution.) - Runaway autonomous loop: the had_tools loop-back had no ceiling. Bounded by max_autonomous_steps (default 25) with a forced human checkpoint; resets on user input. - Wrong tool protocol in MCP: the prompt told the model to emit <tool_call> XML (a cli-shim artefact) even in MCP, where it's dropped. The tool-protocol section is now backend-conditional (native for mcp/api, XML only for cli). MED: - Experiment lifecycle: run_agent records finalize to done/failed from disk (status/result/error.json) in read_agent_logs, not from a Popen map that dies with the subprocess. - ask_user IPC: requests carry a uuid echoed in the response (no cross-question answers); writes are atomic (temp + os.replace), both sides. - Annotation keys: chat bubbles key on a content hash (stable across resumed sessions) instead of the per-process SSE seq. - annotations.jsonl append is lock-guarded against concurrent thumb clicks. - Backend selection: --backend accepts mcp; a single resolve_backend() is the source of truth for both .mcp.json provisioning and the running backend. LOW: - --allowedTools derived from the tool list (fallback constant) so a new tool can't be silently uncallable. - ask_user exchanges recorded before the trailing assistant text. - find_idea return type corrected to a tuple. Also: changes.md TL;DR intro + "Known issues fixed" section. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Overview
This PR extends the interactive mode manager with a New tool execution backend.
Builds on: #109
Summary of Changes
config/manager.yamlllm_backenddefault removed; auto-detected fromdefault_providerat runtimesrc/interactive/mcp_server.pysrc/interactive/mcp_config.py.mcp.jsonand launches MCP server viasys.executablesrc/interactive/llm_backend.pycreate_backend()auto-detects backend fromdefault_provider:claude→mcp, others →cli(unchanged behavior); new_send_mcp()with line-by-line streaming, IPC watcher, tool echo filter;LLMResponsegainsstreamed,had_tools,ask_user_exchangessrc/interactive/manager.py_agent_step()loops autonomously whenhad_tools=Trueinstead of always pausing for user inputsrc/interactive/tools.pymcp__neurico__prefix before dispatchWhy This Is Needed
The current
clibackend runs the manager via:-p(print mode) means Claude Code runs as a single-shot text generator — no interactive agent loop, no tool execution. The manager captures stdout viaPopenand intercepts all tool calls through a customToolExecutor. This causes two structural problems:Bash,Read,Grep, etc.) are available.ToolExecutorrejects them, but the model keeps trying.<tool_result>XML immediately after<tool_call>blocks — before the real tool has been executed.Both problems stem from the same root: the 5 NeuriCo tools are described as XML text in the prompt, not registered at the API level. MCP fixes this structurally.
How MCP Solves It
With MCP:
stop_reason: tool_use— generation halts at every tool call, real results are injected before generation resumes. Therefore, no chance for fabricating fake tool result.Popen/ stdout capture / XML parsing neededTest
./neurico interactive <idea_name> --provider claudesuccess.