Skip to content

refactor: streamline agent package structure#1683

Merged
yottahmd merged 3 commits intomainfrom
refactor-packages
Feb 15, 2026
Merged

refactor: streamline agent package structure#1683
yottahmd merged 3 commits intomainfrom
refactor-packages

Conversation

@yottahmd
Copy link
Copy Markdown
Collaborator

@yottahmd yottahmd commented Feb 15, 2026

Summary by CodeRabbit

Release Notes

No user-facing changes. This release contains internal improvements to the agent storage architecture with no impact on end-user functionality or behavior.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 15, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR refactors the agent package to expose concrete store interfaces directly from the main agent package instead of the internal/agent/iface subpackage. The changes move store interface definitions (ConfigStore, ModelStore, MemoryStore, DAGMetadataStore) and configuration types (ModelConfig, MemoryContent) to the top-level agent package, add context injection helpers for stores, and update all dependent code to reference the new locations.

Changes

Cohort / File(s) Summary
Core store interface relocation
internal/agent/store.go, internal/agent/iface/store.go, internal/agent/iface/dagstore.go, internal/agent/iface/memory.go
Moved ConfigStore, ModelStore, MemoryStore, DAGMetadataStore interface definitions from iface subpackage to main agent package; removed old iface files.
Store implementations
internal/persis/fileagentconfig/store.go, internal/persis/fileagentconfig/store_test.go, internal/persis/fileagentmodel/store.go, internal/persis/fileagentmodel/store_test.go, internal/persis/filememory/store.go
Updated to reference store interfaces from main agent package instead of iface; type signatures changed from iface.ConfigStore to agent.ConfigStore, etc.
Type relocations (Config/ModelConfig)
internal/agent/model_config.go, internal/agent/store_test.go, internal/agent/api.go, internal/agent/api_test.go, internal/agent/mocks_test.go, internal/agent/presets.go, internal/agent/presets_test.go
Moved ModelConfig and added MemoryContent type to main agent package; updated all references throughout agent module from iface.ModelConfig to ModelConfig.
Context helpers for store injection
internal/agent/contextkeys.go
New file with six public functions (WithConfigStore, GetConfigStore, WithModelStore, GetModelStore, WithMemoryStore, GetMemoryStore) for injecting and retrieving stores from context without creating reverse dependencies.
Exec context refactoring
internal/core/exec/context.go, internal/runtime/context.go
Removed direct agent store fields (AgentConfigStore, AgentModelStore, AgentMemoryStore) and corresponding constructor options from exec.Context; shifted to context-based injection via helpers.
Runtime agent wiring
internal/runtime/agent/agent.go, internal/runtime/builtin/agentstep/executor.go, internal/service/worker/remote_handler.go
Updated to use context helpers (agent.GetConfigStore, agent.GetModelStore, agent.GetMemoryStore) instead of direct context fields; changed agent store type references from iface to agent package.
Policy type relocation
internal/agent/policy.go, internal/agent/policy_test.go
Moved policy types (ToolPolicyConfig, BashRule, BashRuleAction, etc.) from iface to direct agent package usage; updated all policy functions to accept agent types.
Session and system prompt
internal/agent/session.go, internal/agent/system_prompt.go, internal/agent/system_prompt_test.go
Updated MemoryStore and MemoryContent type references from iface to agent package; modified memory loading/injection to use relocated types.
Cache and provider utilities
internal/agent/provider_cache.go, internal/agent/provider_cache_test.go
Updated LLMConfig type references from iface to agent package in ProviderCache methods and helper functions.
Frontend API layer
internal/service/frontend/api/v1/api.go, internal/service/frontend/api/v1/agent_config.go, internal/service/frontend/api/v1/agent_config_test.go, internal/service/frontend/api/v1/agent_models.go, internal/service/frontend/api/v1/agent_models_test.go, internal/service/frontend/server.go
Updated all store type parameters and internal store references from iface package to agent package; changed function signatures in API initialization and mock implementations.
Frontend services
internal/service/frontend/agent_policy.go, internal/service/frontend/agent_policy_test.go
Updated ConfigStore type reference and policy configuration types from iface to agent package in policy hook initialization and test mocks.
Command context initialization
internal/cmd/context.go
Updated agentStores method to return concrete agent store types instead of iface-qualified types.
Remote logging
internal/runtime/remote/log_streamer.go
Added compile-time interface implementation check for exec.LogWriterFactory.

Sequence Diagram(s)

Not applicable for this refactoring PR, as the changes are primarily type relocation and interface reorganization without introducing new control flows or multi-component interactions.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Rationale: This is a wide-spanning refactoring affecting 35+ files with heterogeneous changes across the codebase. While individual changes are mechanical (type name substitutions), the sheer scope requires verifying: (1) all import path updates are consistent, (2) interface definitions moved correctly to new locations, (3) all call sites properly reference relocated types and removed iface imports, (4) context injection via new helpers works correctly in runtime paths, and (5) no compilation or hidden behavioral issues result from the relocation. The changes span multiple layers (agent core, storage, runtime, frontend APIs, services), each requiring careful review of type consistency and proper wiring.

Possibly related PRs

  • PR #1637: Modifies the same API and APIConfig structs in internal/agent/api.go with additional hook and context field additions, making structural changes to the same types being refactored here.
  • PR #1651: Implements model-related functionality (ModelStore, ModelConfig, provider resolution/cache, presets) that directly aligns with and may depend on this PR's type relocation and concrete type exposure.
  • PR #1659: Modifies the same agent APIs and memory-related types (MemoryStore, MemoryContent, session/system prompt wiring) that are being relocated in this PR, creating overlapping changes at the code level.
🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 46.15% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor: streamline agent package structure' accurately describes the main change: moving interfaces and types from the iface subpackage to the agent package level for a cleaner structure.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor-packages

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@yottahmd yottahmd merged commit de49170 into main Feb 15, 2026
5 checks passed
@yottahmd yottahmd deleted the refactor-packages branch February 15, 2026 14:33
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 15, 2026

Codecov Report

❌ Patch coverage is 63.80952% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.84%. Comparing base (d0e9ff5) to head (23982cb).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/agent/contextkeys.go 28.57% 15 Missing ⚠️
internal/runtime/builtin/agentstep/executor.go 0.00% 15 Missing ⚠️
internal/agent/policy.go 80.95% 1 Missing and 3 partials ⚠️
internal/persis/fileagentmodel/store.go 90.00% 2 Missing ⚠️
internal/agent/provider_cache.go 80.00% 1 Missing ⚠️
internal/agent/session.go 66.66% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1683      +/-   ##
==========================================
+ Coverage   69.82%   69.84%   +0.01%     
==========================================
  Files         355      356       +1     
  Lines       39600    39609       +9     
==========================================
+ Hits        27651    27663      +12     
- Misses       9741     9746       +5     
+ Partials     2208     2200       -8     
Files with missing lines Coverage Δ
internal/agent/api.go 69.34% <100.00%> (ø)
internal/agent/model_config.go 96.22% <ø> (ø)
internal/agent/presets.go 100.00% <100.00%> (ø)
internal/agent/system_prompt.go 84.61% <100.00%> (ø)
internal/cmd/context.go 68.62% <100.00%> (ø)
internal/core/exec/context.go 90.90% <ø> (-1.10%) ⬇️
internal/persis/fileagentconfig/store.go 100.00% <100.00%> (ø)
internal/persis/filememory/store.go 82.17% <ø> (ø)
internal/runtime/agent/agent.go 68.67% <100.00%> (+0.26%) ⬆️
internal/runtime/context.go 75.00% <ø> (ø)
... and 8 more

... and 8 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d0e9ff5...23982cb. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant