Skip to content

feat(gastown): custom per-role prompt instructions in town settings#1827

Merged
jrf0110 merged 2 commits intomainfrom
1794-agent-prompts
Apr 7, 2026
Merged

feat(gastown): custom per-role prompt instructions in town settings#1827
jrf0110 merged 2 commits intomainfrom
1794-agent-prompts

Conversation

@jrf0110
Copy link
Copy Markdown
Contributor

@jrf0110 jrf0110 commented Apr 1, 2026

Summary

  • Add custom_instructions field to town config schema, allowing users to append free-text instructions (up to 2000 chars each) to the system prompt for polecat, refinery, and mayor agents
  • Add "Custom Instructions" section to town settings UI with per-role textareas, character counters, and scrollspy nav entry
  • Instructions are appended as a ## Custom Instructions (from town settings) section at the end of each role's system prompt via appendCustomInstructions() in the dispatch path
  • For the mayor (whose prompt lives in AGENTS.md on disk), a new PUT /agents/:agentId/system-prompt container endpoint rewrites AGENTS.md when instructions change, triggered automatically from the updateTownConfig mutation
  • Widens all gastown drawers by ~120px and removes truncate from drawer title headers for better readability

Closes #1794

Verification

  • pnpm typecheck passes (only pre-existing csv-parse/sync error in a migration script)
  • oxfmt --list-different . passes (no formatting issues)
  • Regenerated gastown tRPC type declarations via pnpm build:types

Visual Changes

image

Reviewer Notes

  • The appendCustomInstructions helper in container-dispatch.ts is applied at the single point where systemPrompt is assembled in startAgentInContainer, covering all roles (polecat uses systemPromptForRole, refinery uses systemPromptOverride, mayor uses systemPromptForRole — all get wrapped)
  • Mayor propagation requires special handling because its prompt is written to AGENTS.md (read by kilo serve) rather than passed via the session API. The new updateMayorSystemPrompt() method on TownDO rebuilds the prompt and pushes it to the container when custom_instructions.mayor changes
  • Empty/null instructions inject nothing (no empty section header)
  • The custom_instructions field is fully optional and backward-compatible — existing towns without it behave identically

@jrf0110 jrf0110 self-assigned this Apr 1, 2026
Comment thread services/gastown/src/types.ts
Comment thread apps/web/src/routers/admin/gastown-router.ts
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented Apr 1, 2026

Code Review Summary

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 3
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
cloudflare-gastown/scripts/test-drain.sh 63 Container lookup grabs the first towncontainerdo container, so the script can monitor the wrong town when multiple containers are running.
cloudflare-gastown/scripts/test-drain.sh 123 `grep -c ...
cloudflare-gastown/docs/local-debug-testing.md 272 docker kill $(docker ps -q) kills every running Docker container instead of only the Gastown/Wrangler containers.

Fix these issues in Kilo Cloud

Other Observations (not in diff)

N/A

Files Reviewed (2 files)
  • cloudflare-gastown/docs/local-debug-testing.md - 1 issue
  • cloudflare-gastown/scripts/test-drain.sh - 2 issues

Reviewed by gpt-5.4-20260305 · 171,643 tokens

Comment thread cloudflare-gastown/scripts/test-drain.sh
Comment thread cloudflare-gastown/scripts/test-drain.sh
Comment thread cloudflare-gastown/docs/local-debug-testing.md
@jeanduplessis
Copy link
Copy Markdown
Contributor

Due to the monorepo restructure you will need to recreate this PR on a new branch from main. Pass the prompt found at, https://github.com/Kilo-Org/cloud/blob/main/plans/monorepo-migration-prompt.md, to your coding agent while running in this branch. Please close this PR once done or if you don't plan to proceed with it.

jrf0110 added 2 commits April 6, 2026 16:22
…tion, and bug fixes

- Add Workers AI (Gemma 4 26B) to classify unresolved PR review threads as
  blocking vs non-blocking for auto-merge decisions. Informational comments
  (LGTM, bot status reports) no longer block auto-merge.
- Fix mergePR to try squash/merge/rebase in order instead of hardcoding merge
  method (repos with squash-only policy were failing with 405).
- Fix resetAgent to also zero dispatch_attempts so agents recover immediately
  after container evictions instead of being stuck in exponential backoff.
- Fix code_review=false bypass: fast-track ALL open MR beads (not just those
  with pr_url) to prevent the refinery from being dispatched for code review
  when code_review is disabled.
- Fix cross-tick race in pr_feedback_detected: re-verify PR is still open
  before creating feedback beads to prevent duplicate PRs on merged branches.
- Add AI binding to wrangler.jsonc for both production and dev environments.
- Add diagnostic logging for poll_pr auto-merge flow (allGreen, readySince,
  elapsed/delay, convoy dispatch target branch).
- Update local-debug-testing.md with Workers AI documentation.
Migrated from pre-monorepo branch (1794-agent-prompts) to new monorepo
structure (services/gastown/, apps/web/).

- Add custom_instructions field to town config schema (polecat, refinery, mayor)
- Add Custom Instructions section to town settings UI with per-role textareas
- Instructions appended via appendCustomInstructions() in dispatch path
- Mayor prompt updates rewrite AGENTS.md via PUT /agents/:agentId/system-prompt
- Deep-merge custom_instructions per-role in updateTownConfig
- Propagate mayor instructions from both tRPC and HTTP admin routes
- Widen all gastown drawers ~120px, remove truncate from drawer titles
- Regenerate gastown tRPC type declarations

Closes #1794
@jrf0110 jrf0110 force-pushed the 1794-agent-prompts branch from b6e3da2 to 256bdcf Compare April 7, 2026 01:10
@jrf0110 jrf0110 changed the base branch from main to gastown-staging April 7, 2026 01:10
@jrf0110
Copy link
Copy Markdown
Contributor Author

jrf0110 commented Apr 7, 2026

Rebased onto gastown-staging with the monorepo restructure applied. All file paths updated from cloudflare-gastown/services/gastown/ and src/apps/web/src/. The docs and test-drain script were already on gastown-staging so they're excluded from this PR's diff now. Target branch changed to gastown-staging.

@jrf0110 jrf0110 changed the base branch from gastown-staging to main April 7, 2026 01:17
@jrf0110 jrf0110 merged commit 8964e35 into main Apr 7, 2026
19 of 20 checks passed
@jrf0110 jrf0110 deleted the 1794-agent-prompts branch April 7, 2026 01:23
jrf0110 added a commit that referenced this pull request Apr 7, 2026
…1827)

* fix(gastown): auto-merge pipeline fixes, Workers AI thread classification, and bug fixes

- Add Workers AI (Gemma 4 26B) to classify unresolved PR review threads as
  blocking vs non-blocking for auto-merge decisions. Informational comments
  (LGTM, bot status reports) no longer block auto-merge.
- Fix mergePR to try squash/merge/rebase in order instead of hardcoding merge
  method (repos with squash-only policy were failing with 405).
- Fix resetAgent to also zero dispatch_attempts so agents recover immediately
  after container evictions instead of being stuck in exponential backoff.
- Fix code_review=false bypass: fast-track ALL open MR beads (not just those
  with pr_url) to prevent the refinery from being dispatched for code review
  when code_review is disabled.
- Fix cross-tick race in pr_feedback_detected: re-verify PR is still open
  before creating feedback beads to prevent duplicate PRs on merged branches.
- Add AI binding to wrangler.jsonc for both production and dev environments.
- Add diagnostic logging for poll_pr auto-merge flow (allGreen, readySince,
  elapsed/delay, convoy dispatch target branch).
- Update local-debug-testing.md with Workers AI documentation.

* feat(gastown): custom per-role prompt instructions in town settings

Migrated from pre-monorepo branch (1794-agent-prompts) to new monorepo
structure (services/gastown/, apps/web/).

- Add custom_instructions field to town config schema (polecat, refinery, mayor)
- Add Custom Instructions section to town settings UI with per-role textareas
- Instructions appended via appendCustomInstructions() in dispatch path
- Mayor prompt updates rewrite AGENTS.md via PUT /agents/:agentId/system-prompt
- Deep-merge custom_instructions per-role in updateTownConfig
- Propagate mayor instructions from both tRPC and HTTP admin routes
- Widen all gastown drawers ~120px, remove truncate from drawer titles
- Regenerate gastown tRPC type declarations

Closes #1794
jrf0110 added a commit that referenced this pull request Apr 7, 2026
…1827)

* fix(gastown): auto-merge pipeline fixes, Workers AI thread classification, and bug fixes

- Add Workers AI (Gemma 4 26B) to classify unresolved PR review threads as
  blocking vs non-blocking for auto-merge decisions. Informational comments
  (LGTM, bot status reports) no longer block auto-merge.
- Fix mergePR to try squash/merge/rebase in order instead of hardcoding merge
  method (repos with squash-only policy were failing with 405).
- Fix resetAgent to also zero dispatch_attempts so agents recover immediately
  after container evictions instead of being stuck in exponential backoff.
- Fix code_review=false bypass: fast-track ALL open MR beads (not just those
  with pr_url) to prevent the refinery from being dispatched for code review
  when code_review is disabled.
- Fix cross-tick race in pr_feedback_detected: re-verify PR is still open
  before creating feedback beads to prevent duplicate PRs on merged branches.
- Add AI binding to wrangler.jsonc for both production and dev environments.
- Add diagnostic logging for poll_pr auto-merge flow (allGreen, readySince,
  elapsed/delay, convoy dispatch target branch).
- Update local-debug-testing.md with Workers AI documentation.

* feat(gastown): custom per-role prompt instructions in town settings

Migrated from pre-monorepo branch (1794-agent-prompts) to new monorepo
structure (services/gastown/, apps/web/).

- Add custom_instructions field to town config schema (polecat, refinery, mayor)
- Add Custom Instructions section to town settings UI with per-role textareas
- Instructions appended via appendCustomInstructions() in dispatch path
- Mayor prompt updates rewrite AGENTS.md via PUT /agents/:agentId/system-prompt
- Deep-merge custom_instructions per-role in updateTownConfig
- Propagate mayor instructions from both tRPC and HTTP admin routes
- Widen all gastown drawers ~120px, remove truncate from drawer titles
- Regenerate gastown tRPC type declarations

Closes #1794
kilo-code-bot Bot pushed a commit that referenced this pull request Apr 8, 2026
…1827)

* fix(gastown): auto-merge pipeline fixes, Workers AI thread classification, and bug fixes

- Add Workers AI (Gemma 4 26B) to classify unresolved PR review threads as
  blocking vs non-blocking for auto-merge decisions. Informational comments
  (LGTM, bot status reports) no longer block auto-merge.
- Fix mergePR to try squash/merge/rebase in order instead of hardcoding merge
  method (repos with squash-only policy were failing with 405).
- Fix resetAgent to also zero dispatch_attempts so agents recover immediately
  after container evictions instead of being stuck in exponential backoff.
- Fix code_review=false bypass: fast-track ALL open MR beads (not just those
  with pr_url) to prevent the refinery from being dispatched for code review
  when code_review is disabled.
- Fix cross-tick race in pr_feedback_detected: re-verify PR is still open
  before creating feedback beads to prevent duplicate PRs on merged branches.
- Add AI binding to wrangler.jsonc for both production and dev environments.
- Add diagnostic logging for poll_pr auto-merge flow (allGreen, readySince,
  elapsed/delay, convoy dispatch target branch).
- Update local-debug-testing.md with Workers AI documentation.

* feat(gastown): custom per-role prompt instructions in town settings

Migrated from pre-monorepo branch (1794-agent-prompts) to new monorepo
structure (services/gastown/, apps/web/).

- Add custom_instructions field to town config schema (polecat, refinery, mayor)
- Add Custom Instructions section to town settings UI with per-role textareas
- Instructions appended via appendCustomInstructions() in dispatch path
- Mayor prompt updates rewrite AGENTS.md via PUT /agents/:agentId/system-prompt
- Deep-merge custom_instructions per-role in updateTownConfig
- Propagate mayor instructions from both tRPC and HTTP admin routes
- Widen all gastown drawers ~120px, remove truncate from drawer titles
- Regenerate gastown tRPC type declarations

Closes #1794
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.

feat(gastown): Custom per-role prompt instructions in town settings

2 participants