Skip to content

fix(session): fail closed when tool-output eviction artifacts are unavailable - #3969

Merged
Yeachan-Heo merged 2 commits into
devfrom
fix/midrun-artifact-fail-closed
Aug 6, 2026
Merged

fix(session): fail closed when tool-output eviction artifacts are unavailable#3969
Yeachan-Heo merged 2 commits into
devfrom
fix/midrun-artifact-fail-closed

Conversation

@Yeachan-Heo

@Yeachan-Heo Yeachan-Heo commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Problem

#3846 CI shard-7 fails:

AgentSession mid-run maintenance outcomes > fails closed when tool-output artifact persistence is unavailable

  • expected: failed
  • received: pruned

Cause

Non-persisted sessions have no durable session-bound artifact store (getArtifactManager() is null). Mid-run #pruneToolOutputs still committed partial non-tool prunes and reported success, so maintenance returned "pruned" instead of fail-closing.

(Prior #3969 draft was incorrectly based on feat/jcode-research / a different prune implementation. This rewrite targets current dev only.)

Fix

  • Production: if tool-output eviction is estimated (prunableCount > 0) but no durable artifact manager exists, return without committing.
  • Test: in-memory session + large tool output; expect "failed" and original tool content retained.

Non-goals

Verification

bun test packages/coding-agent/test/agent-session-midrun-maintenance.test.ts
# 14 pass / 0 fail

@Yeachan-Heo
Yeachan-Heo force-pushed the fix/midrun-artifact-fail-closed branch from 8184cdc to c1038e3 Compare August 6, 2026 22:16
@Yeachan-Heo
Yeachan-Heo changed the base branch from feat/jcode-research to dev August 6, 2026 22:16
@Yeachan-Heo
Yeachan-Heo force-pushed the fix/midrun-artifact-fail-closed branch from c1038e3 to b537d85 Compare August 6, 2026 22:21

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b537d851e9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// ephemeral store (or a visible install failure) instead of silently pruning
// without durable eviction. Fail closed when tool-output eviction is planned
// but no artifact store can be established.
const artifactManager = await this.sessionManager.ensureArtifactManager();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add the session fix to the package changelog

This changes the user-visible mid-run maintenance outcome and artifact-preservation behavior in packages/coding-agent, but the commit adds no entry under packages/coding-agent/CHANGELOG.mdUnreleased, so the fix will be absent from the package's release notes. Add a concise Fixed entry for the fail-closed behavior.

AGENTS.md reference: AGENTS.md:L178-L178

Useful? React with 👍 / 👎.

@Yeachan-Heo
Yeachan-Heo force-pushed the fix/midrun-artifact-fail-closed branch from ee5daf5 to 1e1aab1 Compare August 6, 2026 22:50

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1e1aab10cb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +11660 to +11661
if (!artifactManager && pruneEstimate.prunableCount > 0) {
return undefined;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Fail closed when artifact ID allocation fails

When a session already has an ArtifactManager but its storage is unavailable—for example, the artifact directory becomes read-only, the disk is full, or a managed-store operation fails—this guard is bypassed. The following allocatePath() catch (and the later allocateId() catch) merely disables artifact references, after which pruneToolOutputs still commits truncation notices and rewrites the canonical entries, permanently discarding the original output without an artifact. Treat reservation/allocation failure like a missing manager and abort the prune before committing any mutations.

Useful? React with 👍 / 👎.

gaebal-gajae added 2 commits August 6, 2026 23:26
…vailable

Port the midrun fail-closed contract onto current dev's prune path: use
ensureArtifactManager (so ephemeral install failures are visible) and return
undefined from #pruneToolOutputs when tool-output eviction is planned but no
artifact store can be established. Prevents reporting a successful prune that
skipped durable eviction.

Regression: force ephemeral install failure via SessionManagerTestHooks and
assert mid-run maintenance outcomes "failed" with original tool text retained.

Lore-id: midrun-fc1-devbase
Confidence: high
Scope-risk: narrow
Reversibility: reversible
Tested: not run locally (node-pty unavailable); exact-head CI will verify
Not-tested: full coding-agent shard matrix offline
Drop the extra blank line so check:@gajae-code/coding-agent passes.
@Yeachan-Heo
Yeachan-Heo force-pushed the fix/midrun-artifact-fail-closed branch from 1e1aab1 to 20d8125 Compare August 6, 2026 23:26
Yeachan-Heo pushed a commit to yazzang-homelab/gajae-code that referenced this pull request Aug 6, 2026
… contention

Root cause: the first Bun probe child absorbs cold compile of the probe + env
module graph. Under coding-agent shard contention that cold start can exceed
the 60s per-test budget (observed 60001ms on Yeachan-Heo#3969 exact-head) while the four
sibling cases complete in ~300ms once the module graph is warm.

Fix (harness isolation, assertions unchanged):
- beforeAll warmup spawn (120s suite budget) moves cold-start outside it()
- resolveIn kills stalled children at 45s with a diagnostic instead of leaking
  pipes until the outer it() timeout

Not a third blind per-test timeout bump; the 60s it() budgets stay.

Lore-id: smithery-spawn-isolation-1
Confidence: high
Scope-risk: narrow
Reversibility: trivial
Tested: not fully offline (local natives missing); exact-head CI verifies
Not-tested: full parallel shard matrix offline
@Yeachan-Heo
Yeachan-Heo merged commit e9e1f3e into dev Aug 6, 2026
46 of 47 checks passed
Sign up for free to 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