Skip to content

fix: rotate worker sessions after each LLM call and add recall error handling#38

Merged
BYK merged 1 commit intomainfrom
fix/worker-session-rotation-and-recall-errors
Mar 12, 2026
Merged

fix: rotate worker sessions after each LLM call and add recall error handling#38
BYK merged 1 commit intomainfrom
fix/worker-session-rotation-and-recall-errors

Conversation

@BYK
Copy link
Owner

@BYK BYK commented Mar 11, 2026

Bug 1: "Multiple reasoning_opaque values received in a single response"

Worker sessions for distillation and curation were reused across multiple LLM calls via ensureWorkerSession(). Each call's assistant response (with reasoning/thinking parts) accumulated in the session history. When a subsequent call sent this history back, the provider rejected it with "Multiple reasoning_opaque values".

Fix: Delete the parent→worker mapping from the workerSessions Map immediately after reading the response in all 4 functions (distillSegment, metaDistill, curator.run, curator.consolidate). Each LLM call now gets a fresh session. Worker session IDs remain in the workerSessionIDs Set so shouldSkip() still recognizes them.

Bug 2: Recall returns nothing after an error

The recall tool's execute() in src/reflect.ts had no try/catch. If any of the three search calls threw, the entire tool execution failed and returned nothing.

Fix: Wrap each search call (temporal.search, searchDistillations, ltm.search) in independent try/catch blocks so partial results are returned even if one source fails. Errors are logged via log.error().

Changes

  • src/distillation.ts: Add workerSessions.delete() after session.messages() in distillSegment() and metaDistill()
  • src/curator.ts: Same pattern in run() and consolidate()
  • src/reflect.ts: Add import * as log, wrap each search in try/catch with log.error()

All 194 existing tests pass.

@BYK BYK enabled auto-merge (squash) March 11, 2026 22:40
…handling

Bug 1: Worker sessions were reused across multiple LLM calls in
distillation and curation. Each call's assistant response with
reasoning/thinking parts accumulated in the session history. When the
next call sent the full history back, providers rejected it with
'Multiple reasoning_opaque values received in a single response'.

Fix: Delete the parent→worker mapping from the workerSessions Map
immediately after reading the response in all 4 functions
(distillSegment, metaDistill, curator.run, curator.consolidate). This
ensures each LLM call gets a fresh session. Worker session IDs are
kept in workerSessionIDs Set so shouldSkip() still recognizes them.

Bug 2: The recall tool's execute() had no try/catch. If any of the
three search calls (temporal.search, searchDistillations, ltm.search)
threw, the entire tool execution failed and returned nothing.

Fix: Wrap each search call in independent try/catch blocks so partial
results are returned even if one source fails. Errors are logged via
log.error() (always visible).
@BYK BYK force-pushed the fix/worker-session-rotation-and-recall-errors branch from ccaad14 to 998273a Compare March 12, 2026 11:21
@BYK BYK merged commit 079089f into main Mar 12, 2026
1 check passed
@BYK BYK deleted the fix/worker-session-rotation-and-recall-errors branch March 12, 2026 11:21
@craft-deployer craft-deployer bot mentioned this pull request Mar 12, 2026
2 tasks
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