Skip to content

Decompose Agent struct: extract ProviderState, SessionState, UiState, OrchestrationState #1731

@bug-ops

Description

@bug-ops

Problem

Agent<C> in crates/zeph-core/src/agent/mod.rs has 40+ fields and 9 #[allow(clippy::too_many_lines)] suppressions. While sub-structs (MemoryState, SkillState, McpState, IndexState, RuntimeConfig, SecurityState, DebugState) were extracted previously, many fields remain directly on the struct.

Proposed Changes

Extract additional sub-structs:

  1. ProviderStateprovider, summary_provider, judge_provider, judge_detector, server_compaction_active, provider_override
  2. SessionStatemessages, pending_image_parts, cached_prompt_tokens, message_queue
  3. UiStatemetrics_tx, cancel_signal, cancel_token, start_time, warmup_ready, cost_tracker
  4. OrchestrationStatepending_graph, plan_cancel_token, subagent_manager, subagent_config, orchestration_config

Motivation

  • Reduce cognitive load when reading the agent struct
  • Enable isolated unit testing of sub-components
  • Align with the established pattern already used for MemoryState, SecurityState, etc.
  • Remove clippy::too_many_lines suppressions by making method bodies smaller

Acceptance Criteria

  • Agent struct has <= 15 top-level fields (composed from sub-structs)
  • No new #[allow(clippy::too_many_lines)] suppressions added
  • All existing tests pass
  • Builder API remains backward-compatible

Files

  • crates/zeph-core/src/agent/mod.rs (3377 lines)
  • crates/zeph-core/src/agent/builder.rs

Metadata

Metadata

Assignees

No one assigned

    Labels

    archArchitecture and designrefactorCode refactoring without functional changes

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions