Skip to content

Commit 8cffb68

Browse files
ziggyclaude
andcommitted
v0.8.2 — context diet
Cuts tokens wasted on every full-agent turn. Root CLAUDE.md → DEVELOPER.md - The Agent SDK auto-loads every CLAUDE.md from the agent's CWD up to the git root. Runtime agents run from groups/main/, so they were inheriting ~1,330 tokens of developer documentation (key-file table, architecture notes, NanoClaw heritage) into every system prompt. That context belongs in DEVELOPER.md for Claude Code reading the repo, not in a Telegram chat turn. - File unchanged, only name moved. Per-group CLAUDE.md files (groups/{name}/CLAUDE.md) keep their name — those are the runtime instructions and SHOULD load. appendMemoryLog deleted - The orchestrator was writing "- [auto] Handled: <raw Telegram XML preview>" to memory/log.md after every full-agent turn. The agent then re-read that log on every session start, paying tokens to re-ingest message previews from days past. - Logging is now the agent's responsibility. groups/{name}/CLAUDE.md already instructs it to prepend meaningful events. Andy is in the loop for chat turns — trust him + the agent. Removes ~30 lines of index.ts and an unused GROUPS_DIR import. Existing [auto] noise pruned from groups/main/memory/log.md - 74 [auto] entries dropped. File 204 → 86 lines. - Real entries (versions, decisions, debugging notes) preserved. - Gitignored, so this prune is local-only. Verified - 425 tests pass. - Typecheck and build clean. - v0.8.1 was 33 minutes ago — no architectural change here, just context diet. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4c31906 commit 8cffb68

4 files changed

Lines changed: 37 additions & 35 deletions

File tree

CHANGELOG.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
11
# Changelog
22

3+
## v0.8.2 (2026-05-03) — Context diet
4+
5+
Cuts tokens wasted on every full-agent turn.
6+
7+
### Changed
8+
- **Root `CLAUDE.md` renamed to `DEVELOPER.md`.** The Anthropic SDK auto-loads
9+
every `CLAUDE.md` from the agent's CWD up to the git root. The runtime
10+
agent runs from `groups/main/`, so it was inheriting ~1,330 tokens of
11+
developer documentation (architecture notes, key-file table, NanoClaw
12+
heritage) into every system prompt — context that has no business in a
13+
Telegram chat turn. The file is unchanged; only its name moved. Per-group
14+
`CLAUDE.md` files (`groups/{name}/CLAUDE.md`) keep their name and continue
15+
to load as runtime instructions.
16+
- **Orchestrator-side `appendMemoryLog` deleted.** After every Telegram
17+
turn the orchestrator was writing `- [auto] Handled: <raw Telegram XML
18+
preview>` to `memory/log.md`. The agent re-read the log on every session
19+
start, so it was paying tokens to re-ingest message previews from days
20+
past. Logging is now the agent's responsibility — `groups/{name}/CLAUDE.md`
21+
already instructs it to prepend meaningful events. Andy is in the loop
22+
for chat turns; trust him + the agent.
23+
- **Existing `[auto]` noise pruned** from `groups/main/memory/log.md`
24+
74 entries dropped, file went from 204 → 86 lines. Real entries
25+
(shipped versions, decisions, debugging notes) preserved.
26+
27+
### Notes
28+
- Gmail MCP tool definitions (~1,500–3,000 tokens per full-agent turn) is
29+
the next-biggest waste, but no quick fix without an architectural change
30+
(move Gmail to a dedicated email group). SDK doesn't expose
31+
`cache_control` on the system prompt option, so we can't cache MCP tool
32+
defs the way we cached the fast-path system prompt in v0.8.1.
33+
334
## v0.8.1 (2026-05-03) — Fast-path cost levers + reliability nits
435

536
### New
File renamed without changes.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ghostclaw",
3-
"version": "0.8.1",
3+
"version": "0.8.2",
44
"description": "Personal AI assistant. Bare metal, Telegram-only, no containers.",
55
"type": "module",
66
"main": "dist/index.js",

src/index.ts

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
ASSISTANT_NAME,
1010
getDailyBudgetUsd,
1111
DATA_DIR,
12-
GROUPS_DIR,
1312
IDLE_TIMEOUT,
1413
MAIN_GROUP_FOLDER,
1514
MAX_MESSAGES_PER_PROMPT,
@@ -449,38 +448,6 @@ async function handleAgentError(
449448
return false;
450449
}
451450

452-
/**
453-
* Append `- [auto] Handled: ...` under today's heading in the group's
454-
* memory/log.md after a successful turn that actually produced output.
455-
* Best-effort — memory logging must never bring down a conversation.
456-
*/
457-
function appendMemoryLog(ctx: BatchContext, outcome: AgentTurnOutcome): void {
458-
if (!outcome.outputSentToUser) return;
459-
try {
460-
const logFile = path.join(GROUPS_DIR, ctx.group.folder, 'memory', 'log.md');
461-
if (!fs.existsSync(logFile)) return;
462-
const today = new Date().toISOString().slice(0, 10);
463-
const logContent = fs.readFileSync(logFile, 'utf-8');
464-
const taskSummary = currentTasks[ctx.chatJid] || ctx.prompt.slice(0, 120);
465-
const entry = `- [auto] Handled: ${taskSummary.replace(/\n/g, ' ')}`;
466-
if (logContent.includes(`## ${today}`)) {
467-
const updated = logContent.replace(
468-
`## ${today}`,
469-
`## ${today}\n${entry}`,
470-
);
471-
fs.writeFileSync(logFile, updated);
472-
} else {
473-
const updated = logContent.replace(
474-
'---\n',
475-
`---\n\n## ${today}\n${entry}\n`,
476-
);
477-
fs.writeFileSync(logFile, updated);
478-
}
479-
} catch {
480-
// Non-critical — don't fail the session over a log write.
481-
}
482-
}
483-
484451
async function processGroupMessages(chatJid: string): Promise<boolean> {
485452
const ctx = prepareBatch(chatJid);
486453
if (!ctx) return true;
@@ -501,7 +468,11 @@ async function processGroupMessages(chatJid: string): Promise<boolean> {
501468
if (outcome.hadError) return handleAgentError(ctx, outcome);
502469

503470
consecutiveFailures[ctx.chatJid] = 0;
504-
appendMemoryLog(ctx, outcome);
471+
// Memory logging is the agent's responsibility — see groups/{group}/CLAUDE.md
472+
// for the instruction to prepend meaningful events to memory/log.md. The
473+
// previous orchestrator-side auto-write produced "- [auto] Handled: <raw
474+
// Telegram XML preview>" entries that were noise the agent re-read on
475+
// every session start. Removed in v0.8.2.
505476
return true;
506477
}
507478

0 commit comments

Comments
 (0)