Skip to content

fix(agents): stop lean workspace prompts referencing write_todos - #1704

Open
aka-khannaji wants to merge 2 commits into
CodebuffAI:mainfrom
aka-khannaji:fix/1692-lean-workspace-todos
Open

aka-khannaji wants to merge 2 commits into
CodebuffAI:mainfrom
aka-khannaji:fix/1692-lean-workspace-todos

Conversation

@aka-khannaji

Copy link
Copy Markdown

Fixes #1692.

Problem

createBase3({ workspace: true }) removes write_todos from the tool list
(agents/base3.ts:203) and strips the todo guidance from the base prompt, but
the lean context-budget section was appended unconditionally:

leanContextGuidance(compactContext.maxContextLength)

So a Desktop/Cloud workspace root whose catalog row supplies a lean
compaction policy was told, in the same system prompt that withheld the tool:

  • "write the plan with write_todos before editing and keep it current"
  • "After condensing, check your todos and the request"

The second line is also wrong for those roots: remaining todos only survive
condensing when the tool exists, so there is nothing to check.

Change

leanContextGuidance takes an optional { workspace } flag and swaps the two
todo-dependent bullets for workspace-safe wording when it is set:

  • keep a short plan in the reply and update it as you go, since the workspace
    has no to-do tool;
  • after condensing, check that plan and the request.

Non-workspace roots (every CLI root, and workspace roots without a lean policy)
keep the existing text byte-for-byte.

Verification

  • bun test agents/__tests__/base3.test.ts — 24 pass, including a new
    regression test for { lean, workspace: true }
  • bun x tsc --noEmit -p agents/tsconfig.json — clean

Workspace roots drop write_todos from their toolset, but a lean compaction
policy still appended guidance telling them to write a todo plan. Pass the
workspace flag through and keep the plan in the transcript instead.

Fixes CodebuffAI#1692.
@codebuff-team

Copy link
Copy Markdown
Contributor

Nice, surgical fix. The root cause is correctly identified: leanContextGuidance in agents/lean-context.ts was appended unconditionally regardless of whether write_todos was in the tool list for workspace roots, leaving contradictory guidance in the system prompt (telling the model to use a tool it doesn't have, and to "check your todos" when none can survive condensing).

The fix threads an options.workspace flag through createBase3 -> leanContextGuidance and swaps in workspace-safe wording for the two todo-dependent bullets, while leaving the CLI/non-workspace text byte-for-byte unchanged. That's the right scope for this change - it doesn't touch the base prompt or the tool-list logic, just reconciles the lean guidance string with what's already true elsewhere in base3.ts.

The added test in base3.test.ts checks both that the workspace-safe wording appears and that write_todos/your todos don't leak into a workspace+lean prompt, and that the non-workspace lean prompt is untouched - good coverage for a comment-string change like this.

One minor nit: planGuidance/stayGuidance duplicate most of their text between the two branches; a shared template string would reduce drift risk if the wording changes again, but that's stylistic, not a blocker.

This is a small, correct, well-tested change in-scope for the mirror (agents/) and should be straightforward to port.

@codebuff-team codebuff-team added bot:triaged Classified by the community triage bot pr:port-candidate Worth porting into the private source tree labels Nov 23, 2026
The workspace and non-workspace plan/stay bullets duplicated most of
their wording, so a future edit could drift one branch. Both now come
from a single sentence skeleton with the root-specific parts as values.
The CLI text is unchanged byte for byte.
@aka-khannaji

Copy link
Copy Markdown
Author

Good catch on the duplication. Addressed in 40e3d0d: each bullet now has one skeleton (- For any task with more than a couple of steps, ${write}. ${survives} and - Stay within the request. After condensing, check ${check} and the request...), with the root-specific wording carried as write / survives / check values. So the next wording change is one edit instead of four.

The non-workspace text is unchanged byte for byte: both original CLI sentences still render verbatim from leanContextGuidance(maxContextLength). Verified with tsc -p agents/tsconfig.json --noEmit and bun test agents/__tests__/base3.test.ts (24 pass), including the workspace assertion that no write_todos or "your todos" leaks in.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:triaged Classified by the community triage bot pr:port-candidate Worth porting into the private source tree

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lean context-budget guidance tells Desktop/Cloud workspace roots to use write_todos, which they don't have

3 participants