Skip to content

Replace anyhow with typed AgentError in zeph-core agent module #293

@bug-ops

Description

@bug-ops

Problem

zeph-core/src/agent/ modules (mod.rs, context.rs, learning.rs, mcp.rs, streaming.rs, persistence.rs) use anyhow::Result throughout. While project conventions allow anyhow in application code, the agent module has grown into a substantial orchestration layer with well-defined error categories that would benefit from typed errors.

Proposed solution

Introduce AgentError enum in zeph-core/src/agent/error.rs with variants covering all failure modes:

  • LLM errors (LlmError from zeph-llm)
  • Channel errors (ChannelError)
  • Memory/persistence errors (MemoryError)
  • Skill errors (SkillError)
  • Tool execution errors
  • Configuration errors
  • Timeout errors

Replace anyhow::Result in agent methods with Result<T, AgentError>. Keep anyhow only in main.rs entry point.

Affected files

  • crates/zeph-core/src/agent/mod.rs
  • crates/zeph-core/src/agent/context.rs
  • crates/zeph-core/src/agent/learning.rs
  • crates/zeph-core/src/agent/mcp.rs
  • crates/zeph-core/src/agent/streaming.rs
  • crates/zeph-core/src/agent/persistence.rs
  • New: crates/zeph-core/src/agent/error.rs

Part of #282

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions