Skip to content

refactor(server): restructure agent launch guidance as numbered list - #400

Merged
selfcontained merged 3 commits into
mainfrom
agt_e550bee06428/agent-e06428
Apr 24, 2026
Merged

refactor(server): restructure agent launch guidance as numbered list#400
selfcontained merged 3 commits into
mainfrom
agt_e550bee06428/agent-e06428

Conversation

@selfcontained

Copy link
Copy Markdown
Owner

Summary

Rewrites the startup rules that Dispatch injects into every agent launch from a single run-on paragraph into a scannable numbered list, and rephrases the session-rename rule in active voice with a concrete trigger.

The session-rename instruction had degraded over time — agents were skimming past it because:

  • It was buried as the second sentence in a ~2,100-char paragraph with no structure.
  • It was phrased as a deferred conditional ("If your session still has the default generated name, wait until you understand…, then call dispatch_rename_session…"), competing with six surrounding active-voice mandates (dispatch_event, dispatch_pin, create_pr, AutoReview flow, etc.).
  • The guidance had grown ~2.5× since the initial commit (rename, pin types, PR tool, AutoReview) without the rename sentence growing in relative prominence.
  • Unlike dispatch_event and dispatch_pin, it's not reinforced in CLAUDE.md or AGENTS.md.

Changes:

  • apps/server/src/agents/manager.ts: builds rules as a string[], numbers them on output. Rename is now rule fix(web): catch agent-status API failure during terminal reconnect #2, phrased actively: "Name the session. As soon as you understand the user's concrete task — typically on your first substantive reply — call dispatch_rename_session once…". Same rules, same meaning, just structured.
  • apps/server/test/db/agent-manager.test.ts: three assertions updated to match the new wording.

Token cost is within ~1% of the old prose (~20 extra tokens for the numbering).

Test plan

  • pnpm run check — server + web type check
  • pnpm --filter @dispatch/server test — 431 passing, 11 skipped
  • pnpm run test:e2e — 144 passing, 6 skipped
  • Confirm future agent launches show rename more reliably (needs dogfood observation)

🤖 Generated with Claude Code

selfcontained and others added 3 commits April 23, 2026 21:17
Rewrites the launch-time startup rules from a single run-on paragraph
into a scannable numbered list, and rephrases the session-rename rule
in active voice with a concrete trigger ("As soon as you understand
the user's concrete task — typically on your first substantive reply").

The old phrasing — "If your session still has the default generated
name, wait until you understand the user's concrete task, then call
dispatch_rename_session…" — buried the instruction mid-paragraph as
a deferred conditional, competing with surrounding active-voice
mandates (dispatch_event, dispatch_pin, create_pr). Agents were
skimming past it.

No change in meaning or tool usage; token cost is within 1%.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds two structural assertions to agent-manager.test.ts so a
regression that silently re-joined the rules array into a paragraph
(e.g. swapping .join("\n") for .join(" ")) would fail the suite.

Addresses architecture-review feedback on PR #400.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adjustments to the session-rename rule added in the previous commit:

- Drop "concrete task" in favor of "topic of work … topic, task, or
  feature." The name describes the subject of the session, not a
  rigidly-defined unit of work.
- Drop "typically on your first substantive reply" — premature for
  sessions where the topic takes a few turns of back-and-forth to
  surface.
- Drop "call … once" and "Don't rename again unless the user starts
  a separate task or explicitly asks." Replace with explicit
  permission to rename if the work shifts substantially to a new topic.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@selfcontained
selfcontained marked this pull request as ready for review April 24, 2026 03:51
@selfcontained
selfcontained merged commit ff4c90c into main Apr 24, 2026
1 check passed
@selfcontained
selfcontained deleted the agt_e550bee06428/agent-e06428 branch April 24, 2026 03:51
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