Skip to content

Add runtime safeguards for readonly sessions, LLM failures, and summary reuse#39

Closed
junyangyan4-svg wants to merge 1 commit intoadoresever:mainfrom
junyangyan4-svg:codex/readonly-guard-summary-reuse
Closed

Add runtime safeguards for readonly sessions, LLM failures, and summary reuse#39
junyangyan4-svg wants to merge 1 commit intoadoresever:mainfrom
junyangyan4-svg:codex/readonly-guard-summary-reuse

Conversation

@junyangyan4-svg
Copy link
Copy Markdown

Summary

  • make subagent and helper sessions recall-only so ephemeral work does not pollute long-term memory
  • add a cooldown guard for permanent 4xx LLM API failures to stop runaway retry/token burn
  • dedupe community summary generation by reusing cached summaries and embeddings when membership is unchanged

Why

  • Subagents and helper sessions are useful consumers of memory, but they are poor producers of long-term memory. Marking them readonly keeps recall available while reducing noise, database churn, and unnecessary maintenance work.
  • When the configured memory LLM starts returning permanent 4xx failures such as 403/404/422, the current behavior can keep hitting the provider every turn. A short cooldown turns a runaway failure mode into a visible, bounded one.
  • Community summaries are expensive. If a community's members have not changed, or the same member set reappears under a new detected community id, the existing summary and embedding are still valid and can be reused.

Implementation notes

  • add ReadonlySessionRegistry and skip ingest/afterTurn/compact/session_end maintenance for readonly session patterns like agent:...:subagent:..., temp:*, and slug-generator-*
  • add LlmFailureGuard and pause only on permanent 4xx provider failures while resetting immediately after a successful call
  • store a deterministic member_signature for community summaries, backfill existing rows, and reuse prior summaries/embeddings when the signature matches
  • document the new safeguards in both README.md and README_CN.md

Verification

  • npm test
  • npx tsc --noEmit

@adoresever
Copy link
Copy Markdown
Owner

Thanks for the PR. There are conflicts with main now (llm.ts was updated in #38). Could you rebase onto the latest main and resolve? Also since this is a large change (+485 lines), could you split it into separate PRs for each feature (readonly sessions, LLM failure guard, summary reuse)? That would make review easier.

@junyangyan4-svg junyangyan4-svg force-pushed the codex/readonly-guard-summary-reuse branch from 917bb9d to e22f790 Compare April 4, 2026 17:04
@junyangyan4-svg
Copy link
Copy Markdown
Author

I've rebased onto the latest main. You can review the change now.

@junyangyan4-svg
Copy link
Copy Markdown
Author

Superseded by split PRs per review request: #41 (readonly sessions), #42 (summary reuse), and #43 (LLM failure guard).

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.

2 participants