Repository navigation
fix(dsh): defer automatic work until step admission - #1856
Conversation
Teingi
left a comment
There was a problem hiding this comment.
One capture regression remains when a slow pre-step hook runs downstream of PowerContext. Details inline.
| if (content) observation?.record('injection', { state: 'running' }) | ||
| let downstream: PreStepDecision | ||
| try { | ||
| downstream = await input.next() |
There was a problem hiding this comment.
[P2] Start the PowerContext deadline after downstream admission
registerRecall() still starts the default 4-second deadline before this next() call. Moving recall and capture after it allows an accepted downstream hook to exhaust the budget before PowerContext starts. I reproduced this with DSH SDK 0.1.2-rc.1 and a local PowerContext Server: register the native hooks-codex handler during agent/session-start so it runs downstream, and have its UserPromptSubmit command run sleep 5 before allowing the prompt. The base captures the Source successfully (202); this head skips every automatic stage with deadline_exceeded, although the model turn completes normally. This depends on downstream registration order; the default static hook ordering was unaffected. Please start the PowerContext work budget after downstream acceptance while continuing to honor caller cancellation.
Which issue or RFC does this PR close?
Addresses the hook-ordering part of #1785.
Rationale for this change
The DSH automatic pre-step hook previously performed PowerContext work before the downstream hook had admitted the step. Scope resolution, context preparation, prompt capture, and flushing could therefore occur even when a later hook rejected the step or failed.
This change defers all PowerContext side effects until the downstream decision returns
kind: "enter".What changes are included in this PR?
downstream_failedanddownstream_rejectedin runtime observations.Are there any user-facing changes?
Yes. Rejected or failed DSH steps no longer trigger PowerContext requests or automatic capture side effects.
There are no breaking changes to public APIs or persisted formats.
How was this change tested?
pnpm --dir integrations/dsh/plugins/powercontext test:allpnpm --dir integrations/dsh/plugins/powercontext build503 inference_unavailableduring flush.AI usage statement
OpenAI Codex was used for source-code tracing, implementation, regression-test design, and validation. The changes were verified using the repository test suite and build process.