Repository navigation
feat: propose_plan client tool and NEMAR plan-first prompt (E2.1, E2.2) - #688
Conversation
Add the derived propose_plan client tool (analysis tier, python tool bound, declared by the caller), PlanDecision and build_plan_tool_message for /chat/resume, a 409 when the answer kind does not match the parked call, and keep plan answers out of the browser-run budget. Tested: tool binding, schema bounds, real graph parking, and the real app through /chat and /chat/resume (edit, approve, changes, mismatch, budget).
Add CommunityConfig.plan_first_instructions (valid only with quick_model and analysis_model), plan_first_section, and append it to an analysis turn that declares propose_plan. NEMAR sets the text; docs and changelog updated. The widget still does not declare propose_plan, so this is inert in production. Tested: config validation, section present only for analysis plus declared plus configured, absent on quick, undeclared and kill switch, and through the real app.
…lan test bounds from the MAX_PLAN constants (tested)
…pproved, not as failed code (tested)
… tie NEMAR plan tool names to the prompt ladder; note runsCode rule for #662 (tested)
|
Review round 1: outcome for each finding. Fix commits are on this branch (4c9b073 through 4681df8). Tests: the full suite passes (5637) except
|
…ot 'before it was run' (tested)
|
Review round 2 outcomes:
Tested: |
|
PM verdict: ready to merge. Acceptance criteria are covered by tests in test_client_tools.py, test_client_tools_graph.py, test_propose_plan.py (new) and test_plan_first.py (new). Both review rounds have a recorded outcome for every finding. All checks pass (Lint, Test 3.11 and 3.12, Frontend Tests, Docker, notebook site, sync-cors), and the branch is up to date with develop. Squash merging. |
Summary
Backend only. The analysis model can now call
propose_plan {findings, steps: [{title, detail}], est_peak_mb}. Likeexecute_codeit parks the graph,/chat/resumereturns the reader's decision, and the NEMAR prompt tells the analysis model to inspect, propose 3 to 6 steps, then run oneexecute_codeper step (board A2,.context/designs/nemar-ai-ux/WidgetPlan.dc.html).The widget is untouched.
ClientToolController.declaredstill does not declarepropose_plan, so the tool and the prompt text are inert in production until the plan card (E2.3) lands. Tests declare it explicitly.est_peak_mbis only a validated field; the memory budget is E5.1.Commit 1, the tool (E2.1):
PROPOSE_PLAN_TOOL_NAMEis reserved (RESERVED_CLIENT_TOOL_NAMES), which lowers the derivedMAX_CONFIGURED_CLIENT_TOOLSby one.PlanStepandProposePlanArgs(findingsat most 2000, 1 to 8 steps, title at most 120, detail at most 600,est_peak_mbint 0 to 8192). Bound bybuild_client_toolsonly with a python tool bound, the name declared andtier == "analysis", withrequires_permission=False; never on quick, with no tier, or under the kill switch.PlanDecision(extra forbid) andbuild_plan_tool_message: deterministic text with the decision, run mode, numbered steps, whether they differ from the proposal (computed on the server from the parked call), feedback, and for changes "revise the plan and call propose_plan again; run no code".PendingClientCall.runs_codeis False for plans and answering a plan does not spendMAX_BROWSER_RUNS_PER_REPLY(runs_after_answer).ResumeRequest.resultisClientToolResult | PlanDecision.chat_resumechecks, beforeclaim_pending_call, that the answer kind matches the parked call's tool; a mismatch is a 409 and the call stays parked.Commit 2, the prompt (E2.2):
CommunityConfig.plan_first_instructions, valid only withquick_modelandanalysis_model, not blank.src/agents/plan_first.pyplan_first_section(config, tier, declared), appended to the merged instructions increate_community_assistantbesideQUICK_MODE_INSTRUCTIONS.src/assistants/nemar/config.yaml;docs/community-widget.mddocuments the key and the tool; oneCHANGELOG.mdline.Closes #660
Closes #661
Tests
tests/test_tools/test_client_tools.py: binding conditions (declared, python tool, analysis tier; absent on quick, no tier, kill switch), reserved name, schema bounds.tests/test_agents/test_client_tools_graph.py: a real graph parks apropose_plancall withrequires_permissionfalse; invalid args get an errorToolMessage.tests/test_api/test_propose_plan.py(new; real router, real graph,StreamingScriptedChatModel, thetest_model_routing.pyharness):tool_requestfor the plan, resume with edited steps andrun_modereaching the model and the session history, second resume 409,changes_requestedleading to a second plan, code result for a plan call 409 and decision for a code call 409 (both stay parked), 20 plans leave the browser-run budget intact (fails ifruns_after_answercounts plans), undeclared means no tool bound, and the prompt section present or absent per tier, declaration and kill switch.tests/test_agents/test_plan_first.py,tests/test_api/test_tool_results.py,tests/test_core/test_config/test_community.py: the section,PlanDecision, the message text and the config validation. No LLM-marked test (E2.5).Commands run
uv run pytest tests/test_tools/test_client_tools.py tests/test_agents tests/test_api/test_propose_plan.py tests/test_api/test_chat_resume_endpoint.py tests/test_api/test_model_routing.py tests/test_api/test_community_router.py tests/test_core/test_config tests/test_assistants tests/test_frontend -q: 1613 passed, 8 skipped.uv run pytest --cov -q: 5625 passed, 91 skipped, 3 failed, total coverage 85%. The 3 failures are live-network tests unrelated to this change:tests/test_tools/test_hed_suggest.py::test_real_program_suggests_a_schema_tagand twotests/test_tools/test_mcp_client.py::TestAgainstProductionNemartests (the production NEMAR server answered with a D1 error).uv run ruff check . && uv run ruff format --check .: all checks passed, 291 files formatted.