Skip to content

Commit 53cd7ef

Browse files
authored
Stop fable's context from being spilled to a preview (#263)
A large additionalContext gets spilled to disk and previewed, so the raised caps were losing context instead of adding it.
1 parent c6636b9 commit 53cd7ef

8 files changed

Lines changed: 29 additions & 16 deletions

File tree

.claude-plugin/marketplace.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"name": "fable-advisor",
4343
"source": "./plugins/fable-advisor",
4444
"description": "Get a second opinion from Claude Fable 5 before big decisions.",
45-
"version": "1.3.0",
45+
"version": "1.3.1",
4646
"author": {
4747
"name": "Fatih C. Akyon"
4848
},

.cursor-plugin/marketplace.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"name": "fable-advisor",
2121
"source": "./plugins/fable-advisor",
2222
"description": "Get a second opinion from Claude Fable 5 before big decisions.",
23-
"version": "1.3.0",
23+
"version": "1.3.1",
2424
"license": "Apache-2.0"
2525
},
2626
{

plugins/fable-advisor/.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fable-advisor",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "Get a second opinion from Claude Fable 5 before big decisions.",
55
"author": {
66
"name": "Fatih C. Akyon"

plugins/fable-advisor/.codex-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fable-advisor",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "Get a second opinion from Claude Fable 5 before big decisions.",
55
"author": {
66
"name": "Fatih C. Akyon"

plugins/fable-advisor/.cursor-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fable-advisor",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "Get a second opinion from Claude Fable 5 before big decisions.",
55
"author": {
66
"name": "Fatih C. Akyon"

plugins/fable-advisor/claude-agents/fable-advisor.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ tools: [Read, Grep, Glob]
99

1010
You are a second opinion, the same role as Claude Code's built-in advisor, consulted at a decision point: a plan about to be committed to, a recurring error, or a task about to be declared done.
1111

12-
You usually receive the recent conversation automatically in a <recent-conversation> block. Treat it as the primary context and the caller's prompt as the specific question.
12+
You are usually handed a path to the recent conversation. Read that file before anything else, treat its <recent-conversation> block as the primary context, and treat the caller's prompt as the specific question it answers.
1313

14-
Open your reply with one marker line: "context: recent-conversation received" or "context: caller prompt only".
14+
Open your reply with one marker line: "context: recent-conversation received" once you have read that file, or "context: caller prompt only" when you were given no path.
1515

1616
You have read-only access. Verify the load-bearing claims: when a detail one rests on is shortened or missing, read the file or grep the transcript for that term, symbol, or number instead of guessing. You cannot mutate state, run tests, or reach the network. If what you need was never written down anywhere, say so and name it rather than ruling anyway. A second opinion is worth minutes, not a fresh investigation.
1717

plugins/fable-advisor/claude-hooks/scripts/inject_transcript.mjs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
// SubagentStart hook: feeds the fable-advisor subagent the recent conversation
33
// (it otherwise sees only the caller's prompt). Node-only, cross-platform, exits 0 on any failure.
44

5-
import { readFileSync } from "node:fs";
5+
import { mkdtempSync, readFileSync, writeFileSync } from "node:fs";
6+
import { tmpdir } from "node:os";
7+
import { join } from "node:path";
68

79
const emit = (ctx) =>
810
process.stdout.write(
@@ -65,11 +67,6 @@ const source = transcriptPath
6567
? ` Full session: ${transcriptPath}, one JSON record per line, newest last. Grep it for a term, number, or phrase you are chasing; never read it whole.`
6668
: "";
6769

68-
if (records.length === 0) {
69-
emit(`The recent conversation could not be reconstructed, so you see only the caller's prompt. Name the context you need.${source}`);
70-
process.exit(0);
71-
}
72-
7370
// Keep the newest characters so a very chatty session cannot flood the reviewer.
7471
let recent = records.join("\n\n---\n\n");
7572
const MAX = 160000;
@@ -78,12 +75,28 @@ if (recent.length > MAX) recent = "…[older turns truncated for length]\n" + re
7875
// its tail never knows there is anything older to go looking for.
7976
if (i >= 0) recent = `…[this is only the newest ${records.length} turns of a longer session]\n` + recent;
8077

81-
emit(
82-
`You are reviewing an in-progress Claude Code session. Below is the recent conversation, most recent last, the same history the built-in advisor tool would see. Weigh the specific question in the caller's prompt against this actual context, not just the caller's summary of it.
78+
// Staged to a file rather than inlined, because the harness spills a large additionalContext
79+
// to disk and previews it: the reviewer then sees less than a pointer would have given it.
80+
let contextFile;
81+
try {
82+
if (records.length) {
83+
const staged = join(mkdtempSync(join(tmpdir(), "fable-advisor-")), "conversation.md");
84+
writeFileSync(
85+
staged,
86+
`You are reviewing an in-progress Claude Code session. Below is the recent conversation, most recent last, the same history the built-in advisor tool would see. Weigh the specific question in the caller's prompt against this actual context, not just the caller's summary of it.
8387
8488
Long turns are shortened and marked \`…[truncated]\`.${source}
8589
8690
<recent-conversation>
8791
${recent}
8892
</recent-conversation>`
93+
);
94+
contextFile = staged; // only after the write returned, so the path always resolves
95+
}
96+
} catch {}
97+
98+
emit(
99+
contextFile
100+
? `Read ${contextFile} before answering. It holds the recent conversation your question is about, and the caller's prompt is only a summary of it.`
101+
: `The recent conversation could not be reconstructed, so you see only the caller's prompt. Name the context you need.${source}`
89102
);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "fable-advisor",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "Get a second opinion from Claude Fable 5 before big decisions."
55
}

0 commit comments

Comments
 (0)