Agent Sandbox Registry

agent-sandbox

Decision: Research-first two-phase clarification (plain research round → structured assessment) on one native session

无英文版

.agents/notes/implemented/architecture/2026-09-29-research-first-two-phase-clarification.md

Decision: Research-first two-phase clarification (plain research round → structured assessment) on one native session

Status: implemented Implemented: 2026-09-29 Related: 2026-09-29-single-question-clarification.md (extends), 2026-09-29-qwen-session-turns-param-unification.md, 2026-09-29-pluggable-coding-agent-backend.md, 2026-09-29-byo-agent-integration-contract.md

Problem

The single-question clarification loop asked the user first and asked too much. For a description like "一个 sandbox 里面运行 Serverless Devs CLI" the old flow could ask whether the tool is Node.js-based, what its official install method is, or which common dependencies it needs — all publicly verifiable facts the agent could have researched itself. The user was being used as a search engine for information the tool stack already knows.

Two structural constraints made "just let the agent research" non-trivial:

  1. --json-schema ends the session early. Verified against the local qwen-code 0.15.11 --help (not from memory): --json-schema is headless-only and "Registers a synthetic structured_output tool; the session ends on the first valid call". Running research inside the structured round would cut the tool loop before any research happened.
  2. The research must use the agent's own tools, not a hand-rolled searcher. Agent Sandbox must not re-implement a web-search client or an agent loop; the task forbids growing one.

Separately, the interaction contract had three UX gaps: the prompt showed an internal cap (Q1/5) that meant nothing to users; a model could repeat an already-answered question; and answers like "你自己决定" / "you decide" (delegating the choice back to the agent) were treated as opaque strings instead of the instruction they are.

Verified facts (qwen-code 0.15.11, 2026-09-29)

Re-verified on this machine via ~/.abx/bin/qwen --help plus a source-level read of the shipped cli.js (no credentials were read; live model calls were not available):

Decision

Two phases on ONE native session

Generation later resumes the same session, so the model keeps the description, the research summary, and every Q/A pair in its own memory — Agent Sandbox never replays the transcript by hand.

What counts as a question

Publicly verifiable facts are complete by definition. The rule lives in three reinforcing places: the schema field descriptions (question "never about public facts such as the tool stack, the official install method, or common dependencies"; missing "Public facts must not appear here"), the assessment prompt's four judgement rules, and the research prompt's "don't ask the user" clause. Only user preferences, private constraints, and business decisions the agent cannot infer may count as missing.

UX contract

Protocol change

CodingAgentBackend gains research(prompt, *, workdir, binary, env, session_id) -> bool (delegating to clarify.run_research); the orchestration in _clarify_requirements runs research → assess on round 1 and assess-only (--resume) afterwards. The threshold gate (CLARITY_THRESHOLD = 0.8) remains Agent Sandbox's verdict, not the model's.

Positional prompt convergence

Both runtime call sites now use the positional prompt, per the 0.15.11 / 0.23.0 --help agreement:

The external qwen-code BYO template (qwen {prompt}) already matches; no version branching is required.

Test Strategy

Acceptance criteria

Files changed

Consequences