Files
weichen 6be8980c17
ci / vet-and-test (pull_request) Successful in 38s
Add the working-method base prompt and demote the compose rewrite
Why: User rulings 4 plus the P3 live evidence. The base library taught layout
standards but not how to work: no planning discipline (plan tool used in 2 of
31 tool runs), no retry-escalation rule (same failing call retried verbatim),
no check-API-first rule (phantom API calls), and nothing about edit
granularity - the P3 after-run showed one turn of 27 single-line edits plus a
self-review spiral (117 tools). The final-reply rewrite layer sees only
160-char summaries and fabricated chapters/promised unfinished work; with the
transcript now authoritative the working model already has full evidence, so
per ruling 4 the rewrite defaults off (kept as fallback when a work loop ends
with no user-facing text at all, plus opt-in setting).

Changes: new base.method module (plan-first for 3+ steps, switch approach
after two failures, check API signatures before scripting, batch edits with
multi_edit, persist to completion - never end on a promise, trace numbers/
dates/names back to source material or mark speculation, honest final
report); tool-description overrides for read_file/edit_file/grep/glob/
run_python/run_shell (dedicated tools over cat/sed, build pipeline for Word);
plan reminder now also nudges once when NO plan exists after several tool
turns (ignorable, once per run); runtime.composeFinal default true->false
with empty-body fallback.

Evidence: SELF - TestPlanlessNudgeFiresOnce (fires once, never repeats),
TestResolveSystemDefaultBase updated for the ninth base block; go vet +
go test ./... pass; live before/after on the golden task set recorded on the
phase04 task card per the policy clause.

Impact: Behavior-surface change only; no contract or storage changes.
2026-10-09 23:12:53 +00:00

43 lines
1.1 KiB
Go

package runtime
import (
"context"
"strings"
"testing"
core "agent-system-core"
)
// P4:计划提醒常开——没有任何计划/待办而任务变长时,给一次可忽略的轻提醒;
// 已有计划但停滞的旧提醒行为不变。
func TestPlanlessNudgeFiresOnce(t *testing.T) {
rc := &fakeRunCtx{
ctx: context.Background(),
prof: core.AgentProfile{Model: core.ModelRoute{Chat: "test-model"}},
}
quiet := textDeltaTurn("", toolCall("make_report", "{}"))
turns := [][]interface{}{}
_ = turns
st := &directRun{l: &LLMRunner{}, rc: rc, eff: core.EffectiveSettings{}}
var seen []string
emitReminder := func(turn int) []string {
// 模拟连续工具轮推进。
st.closedToolTurn = true
st.toolTurnsSince++
return st.reminders(turn)
}
for i := 0; i < 3; i++ {
seen = append(seen, emitReminder(i)...)
}
if len(seen) != 1 || !strings.Contains(seen[0], "update_plan") {
t.Fatalf("planless nudge should fire exactly once, got %v", seen)
}
for i := 0; i < 6; i++ {
seen = append(seen, emitReminder(i)...)
}
if len(seen) != 1 {
t.Fatalf("planless nudge must not repeat, got %v", seen)
}
_ = quiet
}