Skip to content

delegate_agent: compact failure/partial-run response by default - #112

Merged
allocsys merged 8 commits into
mainfrom
feat/delegate-agent-compact-failure-response
Aug 28, 2026
Merged

delegate_agent: compact failure/partial-run response by default#112
allocsys merged 8 commits into
mainfrom
feat/delegate-agent-compact-failure-response

Conversation

@allocsys

Copy link
Copy Markdown
Owner

Fixes the known bug logged in plan.md: failed/partial delegate_agent runs used to always dump the full step-by-step transcript regardless of show_transcript. Now the result.failed branch returns a compact structured summary (step count, reason/error, resume_run_id) by default, and only includes the full transcript when show_transcript is explicitly true.

Also includes:

  • A revert of an unintended scope-creep change (the async "still running" poll branch's transcript inclusion was accidentally gated on show_transcript too during development; reverted back to unconditional, matching main).
  • Fixed test/agent-delegate-loop.test.js's broken vi.spyOn(import(...), ...) mocking pattern (doesn't work under Vitest's ESM handling) — replaced with vi.mock(...).
  • New regression tests pinning the poll branch's transcript to stay unconditional, plus an edge-case test for the "no runId" compact-summary case.

CI green on the branch (verify workflow). Full history in plan.md.

…anscript too
The known-bug fix in plan.md was scoped to the failed/partial result path
only (result.failed further down). This branch's earlier commit
(52b9ef6) also changed the "still running" poll branch to gate its
transcript inclusion on show_transcript, which was never part of the
documented bug or its fix, and regressed
test/agent-tools-async.test.js's existing "poll with a fresh checkpoint"
case (which asserts the transcript is included by default while polling,
matching main's behavior). Reverting just that one line back to
unconditional inclusion, matching main -- the compact-failure-summary fix
itself (the result.failed branch) is untouched.
vi.spyOn was being called on the namespace object returned by a dynamic
import() call, which is a fresh Promise each time and whose exports are
non-configurable -- CI failed both cases in this file with "The property
\"runInvestigation\" is not defined on the object." Replaced with
vi.mock(...) on agent_delegate.js (plus the other agent_tools.js
dependencies: agent_checkpoint.js, qstash_client.js, notion/tools.js),
matching the pattern already used by test/agent-tools-async.test.js.
Also fixed the handler lookup: server.tool(name, description, schema,
handler) puts the handler at argument index 3, not 2 (index 2 is the
zod schema object, which isn't callable) -- switched to the
makeFakeServer()/tools-by-name pattern already used elsewhere in this
test suite to avoid hardcoding the index at all.
…act-failure-response fix
1. Poll-branch regression tests: guard against re-gating the async
"still running" poll branch's transcript on show_transcript, which is
exactly the scope-creep bug this branch's fix commit introduced and a
later commit reverted. Two cases -- show_transcript omitted (default
false) and show_transcript explicitly false -- both assert the
transcript is still included, since that branch's transcript was never
part of this doc's compact-failure-response bug and must stay
unconditional (matching main). Needed its own config.js mock
(DELEGATE_AGENT_ASYNC: "qstash") via vi.doMock + vi.resetModules,
since the outer describe block's real config.js defaults to "sync"
(async branch never reachable there). Refactored the previously
inline `isQStashConfigured: vi.fn(() => false)` /
`loadCheckpoint: vi.fn()` mocks into named top-level vars
(mockIsQStashConfigured, mockLoadCheckpoint) so both describe blocks
can configure them independently without redeclaring the mock
factories.
2. Edge case for the result.failed branch itself: a failed result with
no runId renders "Resumable: not resumable" rather than a broken/
empty resume_run_id line -- the compact summary's other branch,
untested until now.
@allocsys
allocsys merged commit 422726b into mainAug 28, 2026
2 checks passed
@allocsys
allocsys deleted the feat/delegate-agent-compact-failure-response branch August 28, 2026 20:39
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@allocsys