Repository navigation
feat(guidance): in-flight user guidance injection - #215
Conversation
Add a lightweight guidance injection pipeline that allows users to inject corrective messages during agent execution. Guidance is picked up at the next context assembly cycle without interrupting streaming. Pipeline: client → ACTION envelope → GuidanceActionHandler → GuidanceQueue → Context.assemble() → STM → LLM New components: - GuidanceQueue: thread-safe FIFO with consume-on-drain semantics - GuidanceActionHandler: guide:inject/list/clear actions - Context._drain_guidance(): drains queue into STM at assemble time Also: /guide CLI command in examples 05/06, headless control-stdin whitelist, 21 unit tests covering queue, handler, and context injection. Closes #201 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c570579824
ℹ️ 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".
Address review feedback: guidance messages were drained only in assemble(), which runs after compress() in assemble_for_model(). This meant guidance payloads bypassed token-budget pruning and could push the final prompt over the context window. Now _drain_guidance() is called in assemble_for_model() before compress(), so guidance participates in MovingCompressor pruning. The drain in assemble() is kept for direct callers (plan loop, execute loop) — it is idempotent on an empty queue. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Re: P1 — Drain guidance before model-side compression Good catch. Fixed in 1e32bbe: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1e32bbe28c
ℹ️ 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".
| self._drain_guidance() | ||
| await self.compress(**options) | ||
| return self.assemble() |
There was a problem hiding this comment.
Drain guidance exactly once before model compression
assemble_for_model() drains pending guidance before await self.compress(...) but then calls self.assemble(), which drains again. In the in-flight injection scenario this feature targets, guidance enqueued while compression is awaiting (e.g., during moving-compressor summarization) is consumed by the second drain and appended after pruning, so it can bypass the context-window budget and violate the documented “next assemble cycle” boundary. Build the assembled context directly after compression (without re-entering assemble()) so late guidance is deferred to the next cycle.
Useful? React with 👍 / 👎.
Summary
/guide <text>or headlessguide:injectactionContext.assemble()cycle (not immediately), ensuring "next assemble" semanticsChanges
dare_framework/guidance/—GuidanceQueue(thread-safe FIFO with consume-on-drain) +GuidanceActionHandler(guide:inject/list/clear)Context.assemble()drains guidance queue into STM at the top of each callbuilder.pycreates GuidanceQueue, passes to Context, registers handlerclient/main.py— adds guide actions to headless control-stdin whitelist/guideCLI commandtest_client_cli_flow.py— updatedactions:listexpected resultData Flow
Test plan
test_guidance_queue.py— 8 tests: enqueue/drain/peek/clear/empty/reject/max_size/timestamptest_guidance_action_handler.py— 6 tests: supports/inject/missing-content/list/clear/lifecycletest_guidance_context_injection.py— 7 tests: inject-at-assemble/consumed-once/no-guidance-unchanged/multiple-order/role-metadata/after-existingCloses #201
🤖 Generated with Claude Code