-
Notifications
You must be signed in to change notification settings - Fork 3
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Problem
In internal/template/render.go, BuildPrompt tracks a token remaining budget and decrements it as sections are appended. At lines 305-307, the budget is decremented after writing the working memory section, then immediately discarded:
wmSection := buildWorkingMemorySection(wm, remaining)
if wmSection != "" {
sb.WriteString(wmSection)
remaining -= CountTokens(wmSection)
_ = remaining // value is never read after this
}
The _ = remaining confirms the value is dead. The footer on line 311 is always appended unconditionally without a budget check. This means:
- The remaining -= line is dead code.
- The footer appends even when the prompt is already at or over the token budget.
- Any section added after working memory in the future would use the wrong (pre-working-memory) remaining value.
Fix
Remove the dead remaining -= and _ = remaining lines. If the footer should respect the token budget, add a guard before appending it.
Location
- internal/template/render.go, lines 303-311 (BuildPrompt)
@claude please implement this
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working