Commit Graph

1397 Commits

Author SHA1 Message Date
Mathews-Tom ab1d7db7d1 Merge remote-tracking branch 'upstream/main' into feat/tree-ask-reanswer
# Conflicts:
#	packages/coding-agent/src/modes/controllers/selector-controller.ts
2026-07-19 15:02:33 +05:30
can1357 ba385a2946 fix(coding-agent): port no-preparation dead-end rescue to the tiered #rescueCompactionDeadEnd API
Main renamed/refactored #tryShakeRescueForDeadEnd + #emitShakeRescueNotice into
the tiered #rescueCompactionDeadEnd (elide, then image drop, notices emitted
internally), so a textually-clean merge of this branch left calls to undefined
private methods. Re-express the !preparation rescue through the new API:
progress = prepareCompaction succeeding on the rewritten branch, skipElide when
falling through from a shake pass (the image tier still gets a chance), and
historyRewritten flagged whenever a tier freed content even without progress.

Restore the baseline dead-end remedy text (image drop is automated now, so the
manual /shake images suggestion is stale) and align the rescue-refit regression
test with main's continuation gating (auto-continue after compaction now
requires an active goal or queued work).
2026-07-18 21:01:58 +02:00
can1357 401fca701b Merge PR #5448: fix(coding-agent): rescue snapcompact dead-end when nothing is summarizable (@roboomp) 2026-07-18 21:01:41 +02:00
can1357 a762379363 Merge PR #5792: fix(session): resume stalled Cursor tool turns (@roboomp) 2026-07-18 20:12:47 +02:00
can1357 3863a1fac6 Merge PR #5911: fix(subagent): skip session title generation for headless subagents (@roboomp) 2026-07-18 19:57:44 +02:00
can1357 8af064002f Merge PR #5941: fix(coding-agent): parallelize session teardown (@roboomp) 2026-07-18 19:57:43 +02:00
can1357 822e461b5a Merge PR #5942: fix(coding-agent): drain advisor reviews in print mode (@paralin)
# Conflicts:
#	packages/coding-agent/test/print-mode-working-indicator.test.ts
#	packages/coding-agent/test/silent-abort-print-mode.test.ts
2026-07-18 19:43:17 +02:00
can1357 65534c5c07 Merge PR #5947: perf(session): memoize convertToLlm and estimateTokens over settled history (@roboomp) 2026-07-18 19:42:52 +02:00
can1357 55b5a8d73c Merge PR #5962: fix(session): discard capped zero-block assistant stops (@roboomp) 2026-07-18 19:42:52 +02:00
can1357 37456c5f4b fix(coding-agent/session): cleared todo reminder and track assistant message synchronously
- Moved `#todoReminderAwaitingProgress` clearing into tool result handler for synchronous state update.
- Moved `#lastAssistantMessage` tracking to message_end to prevent stale reads when events land in same tick.
2026-07-18 18:56:32 +02:00
can1357 133af40c03 feat(session): serialized subscriber fan-out to prevent event reordering
- Added `#subscriberEmitGate: Promise<void>` FIFO ticket to order concurrent `#emitSessionEvent` calls and prevent event reordering.
- Modified `#emitSessionEvent` to serialize subscriber fan-out: waits for previous gate before emitting, ensuring `message_start` arrives before `message_end` regardless of extension handler asymmetry.
- Added `#prunedTerminalRefusal` field to retain classifier-refusal turns for post-settle readers.
2026-07-18 17:51:51 +02:00
can1357 c655db4e3c fix(session): added #prunedTerminalRefusal field to store the
- Added `#prunedTerminalRefusal` field to store the pruned refusal for post-settle consumers.
- Modified `getLastAssistantMessage()` to return the pruned refusal before active-context lookup.
- Reset `#prunedTerminalRefusal` on `agent_start` so a fresh run supersedes the settled refusal.
- Updated test mock helpers to include `getLastAssistantMessage` for consistency.
2026-07-18 17:51:48 +02:00
Christian Stewart c8f1972c8c fix(coding-agent): drain advisor reviews in print mode 2026-07-18 01:51:00 -07:00
roboomp 2481a4c51a fix(session): awaited capped empty-stop persistence
Waited for the final assistant message_end persistence slot before reparenting past the capped empty turn.

Added a delayed extension hook regression proving the prompt cannot settle before persistence and the active branch remains clean.
2026-07-18 05:34:52 +00:00
roboomp 02443a1c5b fix(session): discarded capped empty assistant stops
Removed the final zero-content assistant after the empty-stop retry cap so its failed-request usage cannot re-anchor context maintenance.

Made the terminal error name model switching and /shake images as recovery options.

Fixes #5959
2026-07-18 05:27:30 +00:00
roboomp a28eb0f470 perf(session): memoized convertToLlm and estimateTokens over settled history
Long sessions re-walked the full live AgentMessage[] every turn: convertToLlm
re-converted the unchanged prefix and estimateTokens re-tokenized settled tool
results and assistants, redoing work only the newest suffix can change.

- Added a per-message estimate cache in agent-core keyed by identity, with a
  settle gate (assistants cache only with real usage + terminal non-error
  stopReason; streaming partials bypass) and dual option-split WeakMaps for the
  default vs compaction-floor estimates.
- Memoized convertToLlm per message identity + assistant interruptedNext flag,
  with an exact-repeat outer-array reuse and slice-on-growth for append-only
  turns, guarded by a boundary-identity check against interior splice-replaces.
- Invalidated both caches at the mutation seams: prune, shake, strip-images, and
  the prewalk plan-nudge scrub, via invalidateMessageCache /
  registerMessageCacheInvalidator across the package boundary.
- Added the llm-assembly bench (N=5000, robust MAD-noise gate): steady/append
  convert and repeat estimate are all >10x faster with noise under 20%.

Fixes #5934
2026-07-18 02:04:09 +00:00
roboomp 10ec14d94d fix(coding-agent): parallelized session teardown
Bounded aborted post-prompt drains and ran independent subsystem cleanup under one barrier while preserving writers-before-close ordering.

Kept long interactive shutdowns visible with a delayed status refresh.

Fixes #5932
2026-07-18 00:19:14 +00:00
roboomp 1e209caeee perf(session): gate blob-ref resolution behind synchronous precheck
resolveBlobRefsInEntries handed every non-session entry to the recursive
async resolvePersistedBlobRefs walk, allocating and awaiting child promises
even for plain-text entries with no blob:sha256: refs. On large text-heavy
histories this dominated the blob_resolve phase of session open.

Add a cheap synchronous containsBlobRef precheck that early-exits on the
first ref and allocates nothing. Interleave the precheck with per-entry
initiation so positive entries still start resolution at the same relative
point as the old filter+map schedule (a later entry that gains a ref during
an earlier BlobStore.get is still scanned after that mutation).

Blob-free N=5000 fixture: blob_resolve median 19.5ms -> 1.1ms, zero
BlobStore.get calls.

Fixes #5922
2026-07-17 23:25:16 +00:00
Mathews-Tom 743c8ab7de fix(coding-agent): allow ask re-answer when targeting the active leaf
navigateTree()'s targetId === oldLeafId no-op short-circuit ran before
the ask re-answer probe/completion block, so selecting an ask
toolResult that is already the current leaf silently reported success
without returning reopenAsk or branching a new answer. This happens
when the user interrupts right after answering ask (before a follow-up
assistant message lands) or another caller navigates straight onto the
ask result. Exempt allowAskReopen probes/completions targeting an ask
toolResult from the short-circuit so the two-phase re-answer protocol
still runs.
2026-07-18 03:16:56 +05:30
Mathews-Tom 5633a64213 fix(coding-agent): deobfuscate recovered ask arguments in tree re-answer
The `/tree` ask re-answer recovery path (#recoverAskReanswerQuestions)
read the persisted ask toolCall's raw arguments directly, so when secret
obfuscation is active the recovered question text could still contain
`#HASH#` placeholders instead of the original secret. The live tool
path already deobfuscates via transformToolCallArguments before use;
apply the same deobfuscateToolArguments call to the recovery path.

Wires an optional obfuscator through TestSessionOptions/createTestSession
so tests can exercise sessions with secret obfuscation active, and adds
a regression test confirming the reopened ask picker shows deobfuscated
plaintext rather than the raw placeholder.
2026-07-18 03:03:42 +05:30
roboomp 53a3aef39a fix(subagent): keep title refresh for focusable subagents
Review follow-up: a live subagent focused from the Agent Hub renders its
session name in the status line (session_name segment reads
sessionManager.getSessionName()), so the blanket agentKind === "sub" skip
made the user-enabled title.refreshOnReplan silently ineffective and left
focused subagents untitled after their first todo replan.

Focus only exists in an interactive host, and subagents run in-process, so
gate the skip on a process-global interactive-host flag: subagents skip the
replan title refresh only in non-interactive hosts (print/RPC/ACP/eval/SDK/
CI) where no session tree is focusable. The interactive entrypoint declares
the host via setInteractiveHost(isInteractive); the flag defaults false, so
bun test and headless embedders keep the optimization without leaking state.

Fixes #5910
2026-07-17 21:10:58 +00:00
roboomp b00197b568 fix(subagent): skip session title generation for headless subagents
Subagent sessions run `todo init` per the eager-todo prelude, which
triggered `#scheduleReplanTitleRefresh()` and a tiny-model title
generation call. The result is written to JSONL but never displayed —
subagents surface their registry id and generated task label, not a
session title.

Short-circuit `#scheduleReplanTitleRefresh()` when `#agentKind === "sub"`.
Uses the session-level subagent marker rather than `hasUI` so print/RPC
top-level sessions keep persisting their auto title for `--resume`.

Fixes #5910
2026-07-17 20:42:08 +00:00
Mathews-Tom 8ae0625bae Merge remote-tracking branch 'upstream/main' into feat/tree-ask-reanswer 2026-07-18 01:17:40 +05:30
Mathews-Tom 70990e31e8 fix(tui): skip tool_execution_start bookkeeping entries in ask recovery walk
#recoverAskReanswerQuestions previously bailed on any non-message-typed
ancestor, but #recordToolExecutionStart() appends a custom
tool_execution_start entry between the assistant message and every
toolResult in real persisted sessions. The walk now generically skips
any ancestor that isn't the target assistant message (or a turn-
boundary user message), so the normal single-tool-call ask case
recovers correctly instead of always falling back to a plain leaf
move.
2026-07-18 00:56:48 +05:30
can1357 3df9cb12c1 Merge PR #5883: fix(agent): preserve signed thinking-only stops (@roboomp) 2026-07-17 21:22:06 +02:00
can1357 1311e6440b Merge PR #5809: fix(session): make /new an atomic boundary against queued steers (@roboomp) 2026-07-17 21:22:06 +02:00
can1357 255707426b Merge PR #5846: fix(cli): preserve carriage-return progress boundaries (@roboomp) 2026-07-17 21:22:04 +02:00
Mathews-Tom 0a1013122f Merge remote-tracking branch 'upstream/main' into feat/tree-ask-reanswer 2026-07-18 00:44:26 +05:30
Mathews-Tom 7bdbfad9f5 fix(tui): address ask re-answer review feedback on #5895
- Gate navigateTree()'s ask toolResult reopenAsk protocol behind a new
  allowAskReopen option, set only by the interactive /tree selector.
  Every other navigateTree() caller (extensions, hooks, ACP,
  session-extension actions) now falls through to the pre-#5642 plain
  leaf move instead of reporting a successful no-op navigation.
- Anchor the branch-summary entry collection on targetEntry.parentId
  for an ask re-answer completion so the replaced (abandoned) answer
  is included in the summary instead of silently dropped.
- #recoverAskReanswerQuestions now walks the ancestor chain past
  interleaved sibling toolResults to find the assistant entry that
  actually emitted the ask toolCall, instead of assuming it's the
  toolResult's direct parent.
- Replace the fabricated `as unknown as AgentToolContext` standalone
  tool context in SelectorController#reanswerAsk with
  AgentSession#buildAskReanswerContext(), a fully-typed context
  backed by real session state.
- #reanswerAsk now rejects a chatRedirect ("Chat about this") result
  instead of silently completing the navigation with it.
- Fix the CHANGELOG entry's external-contribution attribution format.
2026-07-18 00:07:18 +05:30
can1357 248421fdf9 fix(coding-agent): fixed xd:// mount notices triggering unsolicited model turns
- Fixed xd:// mount notices forcing their own model turn by deferring them until the next user prompt instead.
- Added `#pendingXdevMountDelta` field and `#takePendingXdevMountNotice()` to coalesce mount/unmount events and ride along with prompts.
- Mount and unmount events that cancel each other out before the next prompt are now dropped from the coalesced delta.
- Notices remain buffered during quiet startup mode (`startup.quiet`) and are delivered on the subsequent user prompt.
2026-07-17 20:36:11 +02:00
Mathews-Tom fcbcf73769 feat(tui): allow re-answering a past ask from the session tree
Selecting an ask toolResult in /tree previously just repositioned the
leaf onto the stale answer without re-running the interactive picker
(issue #5642). navigateTree() now detects an ask toolResult target and
returns { reopenAsk: { toolCallId, questions } } recovered from the
original toolCall's persisted arguments, instead of mutating anything.
The TUI's tree selector re-opens the ask picker via a standalone
AskTool.execute() call (reusing the live tool-execution UI context),
then calls navigateTree() again with { reanswerAskResult } to branch a
*new* sibling toolResult off the same ask toolCall -- the original
answer's branch stays fully reachable. Non-ask toolResults, and ask
toolResults whose original arguments can't be recovered (legacy/
corrupted sessions), keep the existing plain leaf-move behavior.

This implements direction 2 from the issue's maintainer triage
(re-answer as a new sibling branch), not direction 1 (resuming the
agent turn) or direction 3 (docs-only).
2026-07-17 23:29:35 +05:30
roboomp bacc24e12e fix(agent): preserved signed thinking-only stops
- Treated non-empty thinking signatures as terminal provider content.
- Added regression coverage for empty visible thinking with a valid signature.

Fixes #5881
2026-07-17 17:08:15 +00:00
vmcall d944879f21 feat(task): unified structured subagent execution
- Added per-invocation task schemas with strict and permissive validation.
- Shared task and eval agent policy, artifacts, isolation, and lifecycle handling.
- Enabled host-restricted plan-mode eval agents and persisted their capability clamp.

Fixes #5279
2026-07-17 17:36:59 +02:00
roboomp e5f65fcd5f fix(cli): preserved carriage-return progress boundaries
Normalized lone carriage returns before terminal output is buffered while retaining CRLF as a single line boundary across chunk splits.

Fixes #5845
2026-07-17 13:58:45 +00:00
roboomp 67727c8de5 fix(session): resumed queued messages after compaction reconnects
The #5800 drain guard suppressed the abort-finally stranded-message
drain while the session was disconnected from the agent event stream.
newSession/switchSession drop the agent queues on transition, so nothing
is lost there. compact() preserves the queues and only reconnected in
its finally — it never re-drained — so a steer/follow-up arriving during
compaction (async IRC, an xd:// mount notice, an SDK steer) stayed
stranded until the next explicit prompt.

Re-drain in compact()'s finally after #reconnectToAgent (and after the
compaction AbortController is cleared, so isCompacting is false and the
scheduled agent.continue() actually runs). Added a regression test that
queues a follow-up mid-compaction and asserts it resumes.

Fixes #5800
2026-07-17 08:03:03 +00:00
roboomp 4d685bf761 fix(session): made /new an atomic boundary against queued steers
newSession() disconnects the agent listener and awaits abort() before
agent.reset(). abort()'s finally clears #abortInProgress and calls
#drainStrandedQueuedMessages(), which scheduled agent.continue() on the
still-old context — starting an unsolicited provider turn (e.g. from a
queued xdev-mount hidden steer) that raced the reset and appended its
late output to the fresh session.

Guard the drain to no-op while the session is disconnected from the
agent event stream (#unsubscribeAgent === undefined): a transition owns
the queue, and there is no listener to persist or render output. A plain
user-interrupt abort() stays connected, so its legitimate stranded drain
still runs.

Fixes #5800
2026-07-17 07:43:06 +00:00
can1357 eac51b6a04 Merge: darkphilosophy/feat/advisor-per-agent-toggle
Brings the per-advisor toggle, status-line glyphs, quota display, and the
failing-advisor stall/abort fix (f4c8143) onto main's rewritten advisor
runtime. Conflict reconciliation kept main's architecture (fingerprint
prefix reconciliation, host-level onTurnError recovery + fallback chains,
terminal-failure classification) and ported the branch semantics onto it:

- #failing latch: waitForCatchup resolves immediately while an advisor is
  mid-failure; parked waiters wake the moment a turn fails, before any
  async hook or retry sleep.
- Turn-end render containment: a formatter bug restores the cursor/prefix/
  dedup snapshot and never propagates into the primary's turn-end callback
  (per-advisor try/catch boundary in AgentSession).
- Quota pause: when host recovery declines a usage-limit failure, the
  runtime latches quotaExhausted, requeues the batch, and notifies —
  cleared only by an explicit reset.
- Hard halt after a permanent rejection or three backlog-drop cycles.
- #recoverAdvisorTurn also marks usage limits for structural errors thrown
  before any assistant turn is recorded.
2026-07-17 07:37:29 +02:00
DarkPhilosophy f4c81434d0 fix(advisor): never let a failing advisor stall or abort the primary agent
A broken advisor could hold the primary agent on the per-turn catch-up
gate for its full 30s budget while retrying, and an exception thrown from
onTurnEnd propagated into the primary's turn-end callback.

- waitForCatchup resolves immediately while the advisor is mid-failure
  (new #failing latch, set at the failure catch BEFORE any async hook,
  cleared on the next successful turn or reset/seed).
- Every parked waiter is woken the moment an advisor turn fails.
- The turn-end boundary isolates advisor exceptions per advisor: a
  throwing advisor loses its delta, the primary and sibling advisors
  continue untouched.
- A failed render (poisoned message, formatter bug) restores the delta
  cursor and dedup state, so the delta is re-rendered next turn instead
  of silently lost; the size probe itself is guarded and falls back to
  the deferred renderer.
2026-07-17 07:24:30 +03:00
roboomp 39c864034c fix(session): resumed stalled Cursor tool turns
Continued from completed Cursor exec-channel results instead of replaying side effects when the provider stream stalls.

Fixes #5790
2026-07-17 04:10:17 +00:00
can1357 ac3d779fad merge PR #5592 via eval/pr-5592: feat(warp): emit native CLI-agent events 2026-07-17 05:29:29 +02:00
can1357 dee89ed5ae fix(warp): settle deferred handoffs 2026-07-17 05:25:05 +02:00
can1357 b4e46f8fc6 fix(session): tolerated partial extension runners in dispose
Managed-timer cleanup from #5667 is now optional-called so host or test
facades implementing only the dispatch surface do not throw during
dispose; aligned the selector fallback status expectation with #5586's
role-tag casing.
2026-07-17 05:23:00 +02:00
can1357 86b6265ef5 Merge branch 'sweep/2026-07-17' into eval/pr-5592
# Conflicts:
#	packages/coding-agent/test/agent-session-checkpoint-rewind-branch.test.ts
2026-07-17 05:22:52 +02:00
can1357 f36394ef55 style: fixed formatting in merged test and session files 2026-07-17 05:02:31 +02:00
can1357 11a879e993 merge PR #5463 via eval/pr-5463: fix(advisor): anchor context maintenance on provider usage
Semantic merge with #5734 (delivered-prefix reconciliation) and #5748
(fallback chains): kept the coalescing round cap and wip threading,
adopted bounded cursor-preserving maintenance resets and overflow
recovery, and gated late-arrival consumption on coalescing rounds so
both suites' backlog and preserved-updates contracts hold.
2026-07-17 04:55:49 +02:00
DarkPhilosophy 1b4c292f8f Merge remote-tracking branch 'can1357/main' into feat/advisor-per-agent-toggle 2026-07-17 05:47:09 +03:00
DarkPhilosophy 3be0663bf2 fix(advisor): halt permanently rejected advisors and chunk large delta renders
Two shared failure modes with a single misbehaving advisor:

- A permanently rejected request (invalid_request_error, e.g. a model the
  account no longer supports) retried forever: one notice, then silent
  re-attempts on every turn, rebuilding heavy context each cycle. Quota
  exhaustion already paused with a notice; this class now hard-stops the
  runtime after a permanent rejection or three consecutive backlog-drop
  cycles, with a visible notice. An explicit reset (/new, config rebuild,
  restart) re-enables it, and waitForCatchup resolves while halted so the
  primary agent never parks on a runtime that cannot drain.

- The delta render ran synchronously on the event loop; replaying a
  multi-MB transcript after a reset blocked it for 600ms+ per render
  (measured 675ms at ~54MB). Large deltas now render in size- and
  count-bounded chunks that yield between slices (675ms -> single-digit
  ms stalls). Tool call/result pairing survives chunk boundaries via a
  shared whole-delta result index in formatSessionHistoryMarkdown; small
  per-turn deltas keep the synchronous fast path.
2026-07-17 05:47:01 +03:00
can1357 6f42a4375f merge PR #5748 via eval/pr-5748: fix(advisor): apply configured fallback chains 2026-07-17 04:45:46 +02:00
can1357 05e1314bd9 merge PR #5760 via eval/pr-5760: fix(coding-agent): restored xdev for explicit tool sessions
Resolved plan-mode exit overlap with #5662 (kept restore/rollback
structure, routed pending-switch clearing through
clearPendingPlanModelSwitch) and unioned additive test blocks with
#5672/#5662.
2026-07-17 04:42:10 +02:00
can1357 658438b352 merge PR #5747 via eval/pr-5747: fix(session): retained bash ownership across session/branch transitions 2026-07-17 04:40:04 +02:00