From 642ef5b9c16d8d45b1d41274ffefaa13fa3f9ad2 Mon Sep 17 00:00:00 2001 From: Anuar Ustayev Date: Fri, 25 Sep 2026 16:17:41 +0200 Subject: [PATCH] Tell the agent to orient in the project before it edits The work instruction gives the agent the bead and the checkout and nothing about the project itself -- no objective, no conventions -- so it rediscovers all of that by reading files, every run. datc-yft spent 872k input tokens across 177 steps ($2.06) on a task that was in part exploration it could have skipped. A repository usually states its own conventions. The prompt now tells the agent to read the project's guide files first (AGENTS.md, CLAUDE.md, README, CONTRIBUTING, docs/) and skim the neighbouring code before changing anything, so its change fits how the project is already built rather than being a generic version a reviewer has to rework. Prompt-only; adds a test asserting the orientation line is present. Command run: go build ./... && go test ./internal/work/ Output: ok github.com/datopian/openbases/internal/work 0.397s Co-Authored-By: Claude Opus 4.8 --- internal/work/work.go | 17 +++++++++++++++++ internal/work/work_test.go | 15 +++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/internal/work/work.go b/internal/work/work.go index 7ccf7ab..3c29d2c 100644 --- a/internal/work/work.go +++ b/internal/work/work.go @@ -149,6 +149,23 @@ func (j Job) Instructions() string { "Work the bead %s. Read it first, do what it asks, and close it when the work "+ "is done and not before. If you cannot complete it, leave it open and say why "+ "in a comment.%s\n\n"+ + // Project orientation, said because its absence is expensive. + // + // The agent gets the bead and the checkout and nothing about the + // project itself -- no objective, no conventions -- so it + // rediscovers all of that by reading files, every run. datc-yft + // spent 872k input tokens across 177 steps on a task that was in + // part exploration it could have skipped. A repository usually + // states its own conventions; pointing the agent at them first is + // one line and turns a generic reimplementation into a change that + // fits the project a reviewer will accept. + "Before you change anything, get your bearings in this project. If it has "+ + "guide files -- AGENTS.md, CLAUDE.md, README, CONTRIBUTING, or a docs/ "+ + "directory -- read those first, then skim the code next to where you will "+ + "work. They carry the conventions, the build, and the patterns this project "+ + "already uses, so your change matches it rather than being a generic version a "+ + "reviewer has to rework. This is cheap and saves the run that reimplements "+ + "something the project already had a pattern for.\n\n"+ // The premature-stop guard. A run ends when a turn takes no action, so // an agent that thinks out loud without editing or running anything // stops mid-task -- ent4-tek exited after 3 minutes having only diff --git a/internal/work/work_test.go b/internal/work/work_test.go index 7ab6419..1c8797d 100644 --- a/internal/work/work_test.go +++ b/internal/work/work_test.go @@ -108,3 +108,18 @@ func TestAWorkJobNamesTheCheckout(t *testing.T) { } } } + +// A work job tells the agent to orient in the project before it edits. +// +// Without it the agent rediscovers the project's conventions by reading files +// every run: datc-yft spent 872k input tokens across 177 steps, part of it +// exploration it could have skipped. The prompt now points it at the repo's own +// guide files first. +func TestTheWorkPromptTellsTheAgentToGetOriented(t *testing.T) { + got := Job{Kind: KindWork, Cell: "oss", Bead: "wg-1"}.Instructions() + for _, want := range []string{"get your bearings", "AGENTS.md", "CONTRIBUTING"} { + if !strings.Contains(got, want) { + t.Errorf("the instructions do not point the agent at project context (%q):\n%s", want, got) + } + } +}