delegate_agent: compact failure/partial-run response by default - #112
Merged
Conversation
…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.
…ge/fixes found along the way
…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.
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the known bug logged in plan.md: failed/partial
delegate_agentruns used to always dump the full step-by-step transcript regardless ofshow_transcript. Now theresult.failedbranch returns a compact structured summary (step count, reason/error, resume_run_id) by default, and only includes the full transcript whenshow_transcriptis explicitly true.Also includes:
show_transcripttoo during development; reverted back to unconditional, matching main).vi.spyOn(import(...), ...)mocking pattern (doesn't work under Vitest's ESM handling) — replaced withvi.mock(...).CI green on the branch (verify workflow). Full history in plan.md.