Agent: what a day of live use asked for
Twenty-one prompts against the live assistant found one fabricated success,
a model that believed it was 2025, and a describe_garden that was ~450 plop
entries per turn. This is the set of fixes, each traceable to a finding:
- The gardener's LOCAL day travels with the turn (`today` on POST /agent/chat,
sent by the UI like plantedAt) into the system prompt and every dated tool
default. Left to guess, the model dated journal entries a year back; left to
the server, a 9 pm fill landed on UTC's tomorrow.
- describe_garden groups plops by plant — count, where, planted date, days to
maturity — and lists ids only for groups of ≤ 8; list_plantings spells a big
group out on demand and remove_plantings acts on one plant in a bed ("take
the beets out, leave the garlic"), which used to mean 116 single removals.
- New tools: move_planting (keeps the planting date; across beds via the new
MovePlanting, which is why the store's UPDATE now writes object_id),
update_plant, read_history, copy_garden (the "<garden> — <year>" plan
convention). fill_region takes an explicit local rectangle and a seedLotId;
place_planting's radius defaults to one plant (spacing/2) instead of a guess.
- The system prompt states the date and the gardener's units, forbids claiming
a change no tool made, says it cannot undo and points at the Undo button,
asks before clearing beds on an ambiguous sentence, and stops narrating its
own plantings into the journal.
- A mutation aimed at ANOTHER garden inside a turn is recorded under that
garden as its own change set, not filed into the open scope.
- UI: the thread scrolls inside the Assistant panel so the composer stays
put; every tool has a step label; wide tables stay inside the bubble.
Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
@@ -893,3 +893,50 @@ func TestAutoScopedMutationRecordsEvenIfTheCallerWentAway(t *testing.T) {
|
||||
t.Errorf("undo left x at %v, want %v", back.XCM, bed.XCM)
|
||||
}
|
||||
}
|
||||
|
||||
// TestRecordOutsideTheOpenScopeFilesUnderItsOwnGarden — a scope is for ONE
|
||||
// garden, but nothing stops a mutation inside it from touching another garden
|
||||
// the actor can edit (the agent, pointed at "my other garden"). Those revisions
|
||||
// belong to the garden they changed, as their own change set carrying the
|
||||
// scope's source and run id — not to the open scope, whose undo would then
|
||||
// quietly revert rows in a garden nobody is looking at.
|
||||
func TestRecordOutsideTheOpenScopeFilesUnderItsOwnGarden(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
s := newTestService(t, openConfig())
|
||||
owner := seedUser(t, s, "[email protected]")
|
||||
a := seedGarden(t, s, owner)
|
||||
b := seedGarden(t, s, owner)
|
||||
bedB, err := s.CreateObject(ctx, owner, b.ID, ObjectInput{Kind: domain.KindBed, Name: "Bed", XCM: 500, YCM: 500, WidthCM: 200, HeightCM: 200})
|
||||
if err != nil {
|
||||
t.Fatalf("bed: %v", err)
|
||||
}
|
||||
beforeB, _, _ := s.GardenHistory(ctx, owner, b.ID, 0, 0)
|
||||
|
||||
run := "run-1"
|
||||
cs, err := s.WithChangeSet(ctx, owner, a.ID, ChangeSetOptions{Source: domain.SourceAgent, Summary: "a turn on A", AgentRunID: &run},
|
||||
func(ctx context.Context) error {
|
||||
name := "Renamed from A"
|
||||
_, err := s.UpdateObject(ctx, owner, bedB.ID, ObjectPatch{Name: &name}, bedB.Version)
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("WithChangeSet: %v", err)
|
||||
}
|
||||
if cs != nil {
|
||||
t.Errorf("the scope on A wrote change set %d, but nothing in A changed", cs.ID)
|
||||
}
|
||||
afterB, _, _ := s.GardenHistory(ctx, owner, b.ID, 0, 0)
|
||||
if len(afterB) != len(beforeB)+1 {
|
||||
t.Fatalf("B's history grew by %d, want 1", len(afterB)-len(beforeB))
|
||||
}
|
||||
got := afterB[0]
|
||||
if got.Source != domain.SourceAgent || got.AgentRunID == nil || *got.AgentRunID != run {
|
||||
t.Errorf("B's entry = source %q run %v, want the scope's (agent, %q)", got.Source, got.AgentRunID, run)
|
||||
}
|
||||
if _, conflicts, err := s.RevertChangeSet(ctx, owner, got.ID, domain.SourceUI); err != nil || len(conflicts) != 0 {
|
||||
t.Fatalf("undo from B: err=%v conflicts=%+v", err, conflicts)
|
||||
}
|
||||
if d, err := s.DescribeGarden(ctx, owner, b.ID); err != nil || len(d.Objects) != 1 || d.Objects[0].Name != "Bed" {
|
||||
t.Errorf("after undo B is %+v (%v), want the bed's name back", d, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user