Skip to content

Mayor agent completes without using tools — missing GASTOWN_SESSION_TOKEN in local dev #349

@jrf0110

Description

@jrf0110

Problem

When sending a message to the mayor (e.g., "update the readme"), the agent completes immediately without calling any tools (gt_sling, gt_list_rigs, etc.). No beads are created, no work is delegated.

Root Cause

The gastown plugin's createMayorClientFromEnv() requires four env vars: GASTOWN_API_URL, GASTOWN_SESSION_TOKEN, GASTOWN_AGENT_ID, GASTOWN_TOWN_ID. If any is missing, it throws, and the plugin fails to register tools entirely.

In local dev, GASTOWN_JWT_SECRET is bound via secrets_store_secrets in wrangler.jsonc. This uses the Cloudflare Secrets Store, which may not be available in local development. When resolveJWTSecret() returns null:

  1. mintMayorToken() returns null
  2. GASTOWN_SESSION_TOKEN is never set in envVars
  3. kilo serve starts without the token in its env
  4. The gastown plugin calls createMayorClientFromEnv(), which throws
  5. The plugin fails to load — zero mayor tools are registered
  6. The LLM receives a system prompt describing tools that don't exist
  7. With no tools available, the LLM responds conversationally and completes immediately

Evidence

  • Wrangler logs show POST /mayor/completed arriving seconds after POST /mayor/message
  • No POST /api/rigs/.../sling or tool-related requests from the mayor
  • Streamed events show session.error followed by immediate session.idle and agent.exited

Fix Options

  1. Add a .dev.vars file in cloudflare-gastown/ with GASTOWN_JWT_SECRET=<dev-secret> so it's available in local dev
  2. Add a fallback in mintMayorToken() that uses a hardcoded dev secret when ENVIRONMENT === 'development'
  3. Log the error — currently the plugin failure is silent. Add a console.error when createMayorClientFromEnv() throws so it's obvious in logs

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions