Skip to content

Better signal when agent hits MaxTurns #21

@owainlewis

Description

@owainlewis

Problem

`agent.Run` returns `fmt.Errorf("max turns reached")` after `MaxTurns` iterations (default 50). The partial output is discarded and the caller has no signal beyond a generic error string. In the TUI, the user sees a red `!` block with no context.

Proposal

  • Emit an explicit `EventMaxTurnsReached` (or include a typed sentinel error `ErrMaxTurns`).
  • Return the accumulated final text alongside the error so the caller can render what was generated.
  • TUI: render "hit turn limit (50). Reply to continue." as a distinct block, not as a generic error.

Acceptance

  • Callers can distinguish "hit turn limit" from other errors.
  • Partial transcript text is visible to the user.
  • Test in `agent_test.go` drives a fake provider into the limit and asserts the typed error + partial text.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions