Skip to content

Commit cb7650c

Browse files
committed
fix(plugin): yield the prompt-hook registration so the reminder actually lands
The prompt hook was registered without yield*, and hook only registers when its returned Effect runs (PluginHooks.register) - so the hook never landed, the #58287 repro still made the second, unprompted request, and the PR behaved exactly like the base. The registration is yielded now, and the test stub records the callback only when the returned Effect runs (matching real registration), so the new tests fail without the yield* instead of passing vacuously.
1 parent 364b1fd commit cb7650c

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

‎packages/core/src/plugin/plan.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ export const Plugin = define({
6161
// Persisting the reminder before the user's message is admitted gives the
6262
// ordering an explicit `--agent plan` already produces at session creation.
6363
const defaulted = new Set<Session.ID>()
64-
ctx.session.hook("prompt", (event) =>
64+
// `hook` registers only when its returned Effect runs (PluginHooks.register),
65+
// so this must be yielded or the prompt hook never lands (#58287 repro).
66+
yield* ctx.session.hook("prompt", (event) =>
6567
Effect.gen(function* () {
6668
if (defaulted.has(event.sessionID)) return
6769
const session = yield* ctx.session.get({ sessionID: event.sessionID }).pipe(Effect.orDie)

‎packages/core/test/plugin/plan.test.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,15 @@ const run = Effect.fnUntraced(function* (
9494
},
9595
session: {
9696
get: (input) => Effect.succeed({ ...sessionInfo, id: input.sessionID, agent: currentAgent }),
97-
hook: (name, callback) => {
98-
if (name === "context") contextHook = callback as (input: SessionContext) => Effect.Effect<void>
99-
if (name === "prompt") promptHook = callback as unknown as (input: SessionHooks["prompt"]) => Effect.Effect<void>
100-
return Effect.succeed({ dispose: Effect.void })
101-
},
97+
// Record the callback only when the returned Effect runs, matching the
98+
// real registration (PluginHooks.register): a hook registered without
99+
// yield* in the plugin stays invisible to these tests too (#58287).
100+
hook: (name, callback) =>
101+
Effect.sync(() => {
102+
if (name === "context") contextHook = callback as (input: SessionContext) => Effect.Effect<void>
103+
if (name === "prompt") promptHook = callback as unknown as (input: SessionHooks["prompt"]) => Effect.Effect<void>
104+
return { dispose: Effect.void }
105+
}),
102106
synthetic: (input) => {
103107
persisted.push(input.text)
104108
return Effect.succeed(

0 commit comments

Comments
 (0)