Allow async Stop to start a same-session continuation (KV cache)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 125k
- Forks
- 19.5k
- PR merge metrics
- PR metrics pending
Description
What we are trying
knowcards captures durable repo facts at end of turn. The reflect step must run on the same session id and message history so the model reuses KV cache. A separate worker/LLM (truncated transcript) throws that cache away.
We want that continuation after the user-facing turn ends (background / idle wake), not as a fake user message in the middle of the answer.
What Codex does today
- Sync
Stop+decision: \"block\"+reasonworks: Codex creates a new user prompt fromreasonand continues the same session. That keeps KV cache, but it is a user-channel message and it runs immediately. - Docs: a background hook that finishes while no turn is active waits for the next user turn and does not start a new turn.
- Related: async command hooks may still be skipped at load (#34694).
So we cannot both (1) stay on this session for KV cache and (2) defer reflect until the UI has stopped.
Request
Let an async Stop handler start a same-session continuation when it returns decision: \"block\" + reason (or hookSpecificOutput.additionalContext as developer context, not a user prompt).
Ideal shape:
- Same
session_id/ transcript prefix (KV cache hits). - Not a user-visible chat bubble (developer / system reminder).
- May start after the user-facing turn is idle (wake), instead of only attaching to the next human prompt.
Workaround in knowcards
knowcards install codex keeps Stop synchronous for now. Adapter: src/adapters/codex-reflect.ts
Claude Code has asyncRewake (exit 2 wakes the idle session). We use that there. Codex has no equivalent.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the async Stop hook path and comparing it with the synchronous Stop plus decision:block continuation described in the issue. Use src/adapters/codex-reflect.ts in the knowcards repository as a behavioral reference. Done means an async Stop result can defer a same-session continuation until idle without creating a user-visible message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100