Skip to content

Configurable iteration cap with doom-loop detection #245

@bug-ops

Description

@bug-ops

Parent: #239 (Phase B)

Summary

Replace hardcoded MAX_SHELL_ITERATIONS = 3 with configurable limit (default 10) and add doom-loop detection.

Changes

  • crates/zeph-core/src/config.rs: add max_tool_iterations: usize to AgentConfig (default 10)
  • crates/zeph-core/src/agent.rs: use config value instead of constant
  • Doom-loop detection: track last N tool outputs, break on 3 consecutive identical outputs/errors, notify user
  • Per-iteration token budget check (stop if approaching context limit)
  • config/default.toml: add [agent] max_tool_iterations = 10
  • Env var override: ZEPH_AGENT_MAX_TOOL_ITERATIONS

Acceptance criteria

  • Iteration limit configurable via TOML + env var
  • Default raised from 3 to 10
  • Doom-loop detection breaks on 3 consecutive identical outputs
  • Agent stops when context budget nears limit
  • Existing tests updated

Metadata

Metadata

Assignees

No one assigned

    Labels

    M18M18: Tool Orchestration EvolutioncorefeatureNew functionality

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions