Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

fix(planner): few-shot examples that teach the format, not answers - #34

Merged
mkhellat merged 1 commit into
mainfrom
fix/neutral-examples
Nov 26, 2026
Merged

mkhellat merged 1 commit into
mainfrom
fix/neutral-examples

Conversation

@mkhellat

Copy link
Copy Markdown
Owner

The first PR of the agent-loop plan: no pre-fitted content in the prompt. The maintainer ruled out hard-coding: prompts may teach the output format and state facts, never pre-fit answers to particular questions.

Audit of the planner prompt

Item Verdict Here
Ex. 1 "list the files in the current directory" → ls -la pre-fits (it's chat_eval turn 3, and the maintainer's own question) replaced: "show the last three commits" → git log --oneline -3
Ex. 3 "create hello.py" close to chat_eval's "write a C program" replaced: "add a .gitignore that ignores the build directory"
Ex. 6 "how do I see how big a directory is?" → du -sh (added by me in #29) pre-fits chat_eval turn 7 replaced: "what does the -r flag of grep do?"
Ex. 2 pytest, Ex. 4 docstring patch, Ex. 5 plan_error format only kept
Rule 10 "never answer with echo", and #29's echo-only plan check written against one observed failure removed in the agent-loop PR, where the loop replaces them (a useless or refused step becomes an observation)
#28's identity phrases "never claim to be another assistant" / "never say you cannot see the project" the same kind replaced by facts only (model, project, no shell) in the agent-loop PR
Rule 9 (no shell), the tool and patch rules capability facts kept

The new Example 1 was checked against the default allow-list: git log is allowed, while git branch (the first candidate) would have been refused, and an example of a refused command would teach a refusal.

CI skipped ([skip ci]), and why

The change is text in a prompt constant plus one test assertion (the test now checks the reply form, not its words). Nothing here can behave differently on another platform. The full suite passed locally (1897) and ruff is clean. Measurement of the prompt changes comes with the agent-loop PR.

…kip ci]

Two of the planner's few-shot examples pre-fitted answers to questions
of the chat evaluation (scripts/chat_eval.json) and of the maintainer's
own sessions: "list the files in the current directory" -> ls -la, and
"how do I see how big a directory is?" -> du -sh.  A third, "create
hello.py", sat close to its "write a C program" turn.  Examples must
teach the output format, never pre-fit an answer; the maintainer ruled
out such hard-coding.

They are replaced by examples of the same three forms on unrelated
subjects: a command (git log --oneline -3, which the default allow-list
allows -- git branch would be refused), a file_write (.gitignore), and
a reply (grep -r).

* src/codebud/planner.py (LLMPlanner._FEW_SHOT_EXAMPLES): Examples 1, 3
and 6.
* tests/test_reply_or_plan.py: Check the reply form, not its text.
@mkhellat

Copy link
Copy Markdown
Owner Author

Review summary: correct

Condition. Every few-shot example teaches an output form (command, file_write, patch, plan_error, reply) on a subject that matches no chat_eval turn and no turn of the maintainer's sessions; every example command is on the default allow-list.

Verified:

  • git log --oneline -3 and pytest -q pass the safety engine;
  • the three replaced examples keep their forms;
  • the test asserts the reply form;
  • 1897 tests pass.

Merging. CI was skipped on purpose (prompt text only; see the PR body). main has not moved, and the merge commit carries [skip ci].

@mkhellat
mkhellat merged commit 4b4274c into main Nov 26, 2026
@mkhellat
mkhellat deleted the fix/neutral-examples branch November 26, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant