Repository navigation
feat(active-memory): return partial transcript on timeout - #73219
Conversation
Greptile SummaryThis PR adds a
Confidence Score: 3/5Hold for P1 fix — the accidental removal of One clear P1 (unintended removal of
|
| function shouldCacheResult(result: ActiveRecallResult): boolean { | ||
| return result.status === "ok" || result.status === "empty"; | ||
| return result.status === "ok"; | ||
| } |
There was a problem hiding this comment.
empty results silently lost from cache
empty was previously cacheable so that a confirmed "no memories found" result would be reused for cacheTtlMs instead of spawning a fresh recall subagent on every request. Dropping it here means back-to-back prompts with an empty memory store each pay the full subagent cost.
The PR description says "Caching only fires for ok (no caching of partial output)" but that framing is about the new timeout_partial status — empty should remain cached unless there's a deliberate reason to change it.
| function shouldCacheResult(result: ActiveRecallResult): boolean { | |
| return result.status === "ok" || result.status === "empty"; | |
| return result.status === "ok"; | |
| } | |
| return result.status === "ok" || result.status === "empty"; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/active-memory/index.ts
Line: 1019-1021
Comment:
**`empty` results silently lost from cache**
`empty` was previously cacheable so that a confirmed "no memories found" result would be reused for `cacheTtlMs` instead of spawning a fresh recall subagent on every request. Dropping it here means back-to-back prompts with an empty memory store each pay the full subagent cost.
The PR description says "Caching only fires for `ok` (no caching of partial output)" but that framing is about the new `timeout_partial` status — `empty` should remain cached unless there's a deliberate reason to change it.
```suggestion
return result.status === "ok" || result.status === "empty";
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Fixed in f8d0a240ea: shouldCacheResult now caches ok and empty, while timeout_partial remains excluded. I also added tests for the predicate and for repeated NONE recall using the cached empty result.
|
Posted fixes for all three flagged items:
Validation:
Note: I also attempted the requested |
da86586 to
5e96da4
Compare
When the recall subagent times out (race-loss or abort), the embedded Pi agent has often written some assistant output to the session JSONL already. This change reads the partial transcript on timeout, runs it through the same normalize+truncate pipeline as the success path, and returns it as a new `timeout_partial` status. - Adds `timeout_partial` variant to `ActiveRecallResult` - Reads JSONL transcript on timeout via new `readPartialAssistantText` helper - Threads `sessionFile` out of `runRecallSubagent` so the caller can recover partial output even when the subagent never resolves - Surfaces partial output via status line, metadata, and prompt prefix the same as a successful recall - Skips caching for `timeout_partial` (only `ok` results are cached) - Generic `unavailable` path unchanged - Adds 7 tests covering all timeout/abort/error paths Without this, every recall hitting the configured `timeoutMs` ceiling discards work the model has already done.
5e96da4 to
9a61a91
Compare
|
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Keep this PR open. Current main still returns plain Best possible solution: Keep the PR open for maintainer review. The likely path is to review the latest head against What I checked:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 373e7fc24233. |
|
Merged in 1690678 after representative verification with |
🔒 Aisle Security AnalysisWe found 1 potential security issue(s) in this PR:
1. 🟡 Unhandled read stream errors in streaming JSONL transcript reader can crash process
DescriptionThe new In Node.js, an Vulnerable code: const stream = fsSync.createReadStream(params.sessionFile, { encoding: "utf8" });
const rl = readline.createInterface({ input: stream, crlfDelay: Infinity });
for await (const line of rl) { /* ... */ }RecommendationAttach explicit error handling for the underlying stream (and ensure the readline interface is closed) so file disappearance or I/O errors don't become unhandled exceptions. One safe pattern: import { finished } from "node:stream/promises";
const stream = fsSync.createReadStream(params.sessionFile, { encoding: "utf8" });
stream.on("error", () => {
rl.close();
});
const rl = readline.createInterface({ input: stream, crlfDelay: Infinity });
try {
for await (const line of rl) {
// ...
}
} catch {
// best-effort
} finally {
rl.close();
stream.destroy();
await finished(stream).catch(() => undefined);
}At minimum, add Analyzed PR: #73219 at commit Last updated on: 2026-04-28T13:51:25Z |
…3219) Verified: - pnpm test extensions/active-memory/index.test.ts - pnpm exec oxfmt --check --threads=1 extensions/active-memory/index.ts extensions/active-memory/index.test.ts CHANGELOG.md - git diff --check Co-authored-by: joeykrug <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…3219) Verified: - pnpm test extensions/active-memory/index.test.ts - pnpm exec oxfmt --check --threads=1 extensions/active-memory/index.ts extensions/active-memory/index.test.ts CHANGELOG.md - git diff --check Co-authored-by: joeykrug <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…3219) Verified: - pnpm test extensions/active-memory/index.test.ts - pnpm exec oxfmt --check --threads=1 extensions/active-memory/index.ts extensions/active-memory/index.test.ts CHANGELOG.md - git diff --check Co-authored-by: joeykrug <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…3219) Verified: - pnpm test extensions/active-memory/index.test.ts - pnpm exec oxfmt --check --threads=1 extensions/active-memory/index.ts extensions/active-memory/index.test.ts CHANGELOG.md - git diff --check Co-authored-by: joeykrug <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
Summary
When the active-memory recall subagent hits its configured
timeoutMsor is otherwise aborted, the plugin currently discards the partial
output the embedded Pi agent has already written to the session
transcript. This PR recovers that work.
Motivation
Recall runs commonly produce a useful summary in the first 30-60s, then
hit
timeoutMswhile the model is still finishing. Today the user getsnothing —
{ status: "timeout", summary: null }— and the partialtranscript is silently dropped.
Change
timeout_partialvariant inActiveRecallResult.readPartialAssistantText(sessionFile)reads the JSONL on timeout,joins assistant text, returns
nullif empty.timeout_partialwhen partial text is recoverable, ortimeout(unchanged) when nothing was written.
same way
okdoes.ok(no caching of partial output).unavailablepath unchanged.Tests
7 new tests in
extensions/active-memory/index.test.tscover:timeout_partialtimeouttimeouttimeout_partialunavailableshouldCacheResult(timeout_partial) === falseBackward compatibility
timeout_partialis a new discriminant; existing callers thatexhaustively switch on
result.statuswill get a TS error and need tohandle it explicitly (intentional — partial output should be surfaced,
not silently treated as full timeout).
Notes
Reported by Joey Krug; the live config currently has
timeoutMs: 90000on Sonnet 4.6 and was hitting timeouts on long-context Signal recalls.