Repository navigation
Description
Existing issue check
- Searched open issues and historical context/executor reports, including this incident's session ID. No existing issue captures this complete set of newly agreed requirements.
Related work: #1199 (lifecycle/cancellation/capability convergence), #1100 (long-turn compaction continuity), #1220 (stream interruption and orphaned ownership), #988 (completed work reported as incomplete), and #1226 (background lifecycle of the Runner daemon, a different lifecycle from its individual tasks). Reuse these issues for their narrower fixes; this is a tracker for the user journey and acceptance criteria below.
Problem
Astra should provide a stable execution foundation that lets the model complete authorized work and lets users inspect or steer it. Currently, context recovery, capability restrictions, planning approval and task control can interfere with that journey. More error recognition alone will not fix the underlying triggers.
Thinking/reasoning configuration observability has already merged into main and is out of scope. Implement the remaining work against the latest main.
Observed behavior and investigation boundary
Retrospective evidence comes from the local CLI and runtime journals for session c63c6553-8bf6-4cd1-9519-3c873e906c55 (macOS ARM64, CLI + Server). These observations have not all been reproduced on current main.
- Two user turns failed during local
request_preparationwithcontext_window. The first advertised compact-and-retry; the next attempt failed in about 1.85 seconds with no tool execution. The last successful Luna request had estimated input of 240,038 tokens versus 109,919 provider-reported input tokens. The discrepancy and failed recovery are observed; incorrect accounting of opaque Responses reasoning is a candidate cause, not an established root cause. - The user repeatedly requested a local Codex binary review. No Codex process was launched: prompt guidance prohibited provider CLIs through Bash while the advertised collaborator directory was empty. The system offered no executable path for the explicit local request.
- After continuation,
exit_plan_modewas rejected asdeferred_tool_descriptor_stalebefore reaching approval. Re-selecting the same tool and invoking it again succeeded. The exact old/new descriptor difference was not retained in the inspected evidence. - Plan review currently waits for its separate approval UI even in bypass mode; the inspected implementation has no ten-second automatic approval. Its default approval option selects Auto rather than preserving Bypass.
- Subsequent successful validation with different command shapes was not associated with earlier failed validation. The final diagnostic still contained two unresolved
test_failureentries. Historical failures should remain visible without automatically becoming permanent task-incompletion claims. - Foreground-to-background process adoption already exists, but its narrow detachable-command gate admits a few builtins and
sleep, excluding ordinary long tasks such ascargo test.
Desired user journey
- The user starts a long task such as
cargo testor explicitly requests a local program such as Codex. - The selected CLI/Runner starts it under the existing authorization and process owner, with a stable task identity and observable output/status.
- If the user asks a question while the command runs, the same process can continue in the background while the parent model responds. Do not kill and restart it, silently discard its output, or treat the user's message as process stdin.
- Both the user and model can inspect progress, wait, poll when needed, send input where supported, and request cancellation. The UI can display progress without starting another model turn.
- Completion, required input, or a meaningful failure is delivered through the existing task channels. A wait timeout means the task is still running; cancellation acceptance is distinct from confirmed exit.
- Long conversations compact automatically and continue without requiring repeated user prompts or manual model switching.
Scope and acceptance criteria
- Automatic context management: use consistent protocol-aware budget accounting for assembly, compaction and retry; preserve user constraints, active tool relationships and route-bound Responses continuation. Re-measure after compaction and continue when the request fits. Investigate the estimate/provider discrepancy before selecting a fix. Do not promise successful recovery merely because some bytes/tokens were removed, or retry the same ineffective preparation indefinitely.
- Prevent avoidable stale bindings: keep discovery, current admission and execution on the existing registry/owner. Ordinary continuation must not require a failed call just to refresh an unchanged logical tool. Distinguish harmless descriptor refresh from a real schema, authorization or execution-owner change, and retain a bounded diagnostic difference when rejection is necessary.
- Execution facts and task judgment: retain started/running/terminal status, exit code, output, cancellation and explicitly unknown outcomes. Let the model assess task fulfillment from those facts. Simplify exact-command-only failure clearing and resulting misleading terminal notices; do not add a command-equivalence engine or a separate recovery-obligation state machine. Do not automatically repeat a state-changing operation whose outcome is unknown.
- Planning and permission intent: preserve explicit user-requested plan approval. Model-authored planning must not silently add human approval to already authorized bypass work or silently change the selected permission mode. Do not use a countdown as a substitute for clear authorization semantics. Fix the actual pre-approval stale-binding trigger as well as the UX.
- Explicit local program execution: an authorized request to run a local program must have a usable path through the selected CLI/Runner executor. A provider adapter can enhance structured interaction, but an empty provider directory must not itself prohibit an otherwise authorized local command. Keep local files, credentials and processes at the explicitly selected local boundary; do not give the Server implicit local access.
- One process/task owner: reuse and converge existing shell/background-task/process-supervision owners. Start, output capture, cancellation and terminal cleanup must survive foreground/background presentation changes. Support promoting an already-running build/test without restarting it; preserve its process identity, earlier and subsequent output, deadlines and workspace attribution through completion. Remove the narrow command restriction only with that shared lifecycle working.
- Capability-based communication: expose the operations each actual task supports: output/status, wait/poll, input/message, stop and continuation. Ordinary Bash supports dialogue only when its stdin/PTY is available; internal subagents can use existing mailboxes; native Codex can use existing steering/interaction support. Share observation/control semantics without forcing every transport into a chat protocol. Queued or accepted input is not proof of task completion.
- User and model access: allow dynamic task viewing, targeted messages and stopping from the UI and model tools. User input normally addresses the parent; explicitly targeted input goes to the selected child. Supported follow-up/resume must retain the intended task/provider identity. Inspecting a running task must not require interrupting it or taking a new execution lease.
- Efficient waiting: prefer events, bounded waits, incremental output and backpressure while retaining useful on-demand polling. Remove rigid behavioral restrictions such as one observation per turn or requiring the user to literally ask to wait. Avoid per-session periodic database polling and model wakeups for every output chunk. Bound buffers, queues and retained output.
- Actionable diagnostics: typed errors and sufficient source context must reach the model, including the execution stage and whether work started. User-facing messages should explain what is happening and available actions without requiring users to understand descriptors, receipts or internal state machines.
Design and validation constraints
- Find and extend existing owners and callers first. Converge duplicated execution paths, projections and control semantics; remove superseded code, prompts, branches and tests rather than layering compensating logic on top.
- Keep one agent backbone across CLI, Server, Web and User Runner. No new task registry, lifecycle framework, recovery state machine, unnecessary tables, or background polling service for this work.
- Prefer simple executor guarantees and high-quality model context over application rules that interpret task meaning. The model chooses useful work, observations and communication within the user's authorization.
- No legacy compatibility layer is required; preserve the frozen MOI gate contract and its constraints.
- Validate real public journeys and unhappy paths: foreground/background transfer racing with exit, input during a long command, cancellation during transfer, lost input acknowledgements, output failure, reconnect, stale binding, and compaction followed by an actual next request. Preserve useful partial results and avoid false success/failure.
- Assess implementation, tests and documentation separately. Existing tests establish current behavior, not proof that the design is correct. Require explicit rationale when changing a contract; do not treat a failing old assertion alone as a reason to abandon a valid UX fix.
- Provide representative 1,000-session/task scalability evidence where applicable, including database/query rate, empty polling, queue/memory bounds and model wakeups. Do not infer scale from a small concurrent unit test, raise timeouts, or rely on reruns to claim reliability.
Completion means these user journeys work through the existing owners with less unnecessary complexity, not merely that more error categories or guard branches have been added.
Activity