Skip to content

Commit 490cc52

Browse files
authored
fix(coding-agents): bound automatic reflect budget (#3364)
1 parent 07aec3b commit 490cc52

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

hindsight-integrations/coding-agents/src/core/hook.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ describe("buildHookOutput", () => {
152152
expect(client.reflect).toHaveBeenCalledTimes(1);
153153
});
154154

155-
it("caps the reflect timeout at 25000ms even when config asks for more", async () => {
155+
it("uses a bounded low-budget reflect and caps its timeout at 25000ms", async () => {
156156
const cfg = resolveConfig({}); // reflectTimeoutMs default 120000
157157
const client = makeClient();
158158
await buildHookOutput({
@@ -163,7 +163,7 @@ describe("buildHookOutput", () => {
163163
cacheFile,
164164
});
165165
expect(client.reflect).toHaveBeenCalledWith(buildReflectQuery("the prompt"), {
166-
budget: "high",
166+
budget: "low",
167167
timeoutMs: 25000,
168168
});
169169
});
@@ -179,7 +179,7 @@ describe("buildHookOutput", () => {
179179
cacheFile,
180180
});
181181
expect(client.reflect).toHaveBeenCalledWith(buildReflectQuery("the prompt"), {
182-
budget: "high",
182+
budget: "low",
183183
timeoutMs: 5000,
184184
});
185185
});

hindsight-integrations/coding-agents/src/core/hook.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ export async function buildHookOutput(args: {
112112
const t0 = Date.now();
113113
try {
114114
reflectAnswer = await client.reflect(buildReflectQuery(prompt), {
115-
budget: "high",
115+
// Automatic reflection runs inside a hard 25s hook window. Hindsight's low budget is the
116+
// supported default for bounded reflect calls; callers that explicitly invoke the MCP
117+
// tool still get the deeper high-budget path.
118+
budget: "low",
116119
timeoutMs: Math.min(cfg.reflectTimeoutMs, HOOK_REFLECT_CAP_MS),
117120
});
118121
diag(harness, reflectAnswer ? "reflect_ok" : "reflect_empty", {

0 commit comments

Comments
 (0)