Skip to content

fix(smithy): clearer error from sf agent start - #100

Open
komoreka wants to merge 2 commits into
stoneforge-ai:masterfrom
komoreka:fix/agent-start-clarity
Open

komoreka wants to merge 2 commits into
stoneforge-ai:masterfrom
komoreka:fix/agent-start-clarity

Conversation

@komoreka

@komoreka komoreka commented May 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #61.

sf agent start <id> for a worker defaults to headless mode, which feeds prompts via stdin. Without --prompt or --resume the spawned process has no input, exits immediately, and the user sees Failed to start agent: Session exited before init.

This PR makes that path explainable. agentStartHandler now refuses headless invocations with no input source up front and prints the cause plus the three fixes (--prompt, --resume, --mode interactive). The note also clarifies that dispatch-driven workflows respawn workers automatically.

A spawner-side enrichment of the Session exited before init message was considered as a backstop, but the headless path emits a synthetic exit code (0 or 1 derived from resumeErrorDetected) rather than the underlying child process exit, so enriching with that code produces misleading output for the exact case the issue is about. Tracked as a follow-up if a real exit-code propagation path is needed.

The dispatch daemon path is untouched: it always supplies an initialPrompt and never hits this case.

Test plan

  • bun test packages/smithy/src/cli/commands/agent.bun.test.ts (new validation test + all pre-existing tests pass)
  • Workspace turbo typecheck clean
  • pnpm build clean
  • Manual: sf agent start <worker-id> with no flags prints the new validation error; sf agent start <worker-id> --prompt "..." proceeds to spawn.

🤖 Generated with Claude Code

komoreka added 2 commits May 5, 2026 13:15
Headless workers/stewards spawned without --prompt or --resume have no
input source and exit immediately, producing the cryptic 'Session
exited before init' error. Refuse the invocation with a clear message
that names the cause and lists the three fixes (--prompt, --resume,
--mode interactive).

Refs stoneforge-ai#61.

This branch has not been deployed

No deployments
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.

bug: sf agent start fails with 'Session exited before init' on expired ephemeral sessions

1 participant