picoclaw/pkg/agent
sky5454 329e68e017
refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585)
* refactor(agent): introduce interfaces for MessageBus and ChannelManager

Phase 2 of loop.go refactor — dependency inversion using adapter pattern.

- Add interfaces.MessageBus and interfaces.ChannelManager interfaces
- Create adapters/messagebus.go wrapping *bus.MessageBus
- Create adapters/channelmanager.go wrapping *channels.Manager
- Update AgentLoop to use interfaces instead of concrete types
- Update registerSharedTools to accept interfaces.MessageBus

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* refactor(agent): restructure pipeline and rename loop files

Pipeline refactoring:
- Split pipeline.go (1400 lines) into focused files:
  - pipeline_setup.go (~115 lines): SetupTurn method
  - pipeline_llm.go (~519 lines): CallLLM method
  - pipeline_execute.go (~693 lines): ExecuteTools method
  - pipeline_finalize.go (~78 lines): Finalize method
- Pipeline struct and NewPipeline remain in pipeline.go (~39 lines)

Agent file renaming:
- Rename loop_*.go to agent_*.go for consistent naming:
  - loop.go -> agent.go, loop_message.go -> agent_message.go, etc.
- Merge turn.go + turn_exec.go into turn_state.go
- Rename loop_turn.go -> turn_coord.go

Documentation:
- Update docs/pipeline-restructuring-plan.md
- Add docs/agent-rename-plan.md

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(agent): code format  fixed

* refactor(agent): code test file added/renamed

* docs(agent): update agent refactor docs

* fix(agent): fix agent hardAbortX

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-21 10:55:50 +08:00
..
adapters refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00
interfaces refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00
agent.go refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00
agent_command.go refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00
agent_event.go refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00
agent_init.go refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00
agent_inject.go refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00
agent_mcp.go refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00
agent_mcp_test.go refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00
agent_media.go refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00
agent_message.go refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00
agent_outbound.go refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00
agent_steering.go refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00
agent_test.go refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00
agent_transcribe.go refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00
agent_utils.go refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00
context.go fix(agent): preserve reused tool call IDs across turns (#2528) 2026-04-15 20:18:09 +08:00
context_budget.go feat(seahorse): implement short-term memory engine (LCM) (#2285) 2026-04-05 09:05:16 +08:00
context_budget_test.go feat(seahorse): implement short-term memory engine (LCM) (#2285) 2026-04-05 09:05:16 +08:00
context_cache_test.go feat(web): support image messages in pico chat (#2299) 2026-04-03 14:15:20 +08:00
context_legacy.go merge: integrate main seahorse context changes 2026-04-13 23:02:38 +08:00
context_manager.go feat(agent): /clear now clears seahorse DB in addition to JSONL 2026-04-13 11:04:45 +08:00
context_manager_test.go feat(agent): /clear now clears seahorse DB in addition to JSONL 2026-04-13 11:04:45 +08:00
context_seahorse.go feat(agent): /clear now clears seahorse DB in addition to JSONL 2026-04-13 11:04:45 +08:00
context_seahorse_test.go feat(seahorse): implement short-term memory engine (LCM) (#2285) 2026-04-05 09:05:16 +08:00
context_seahorse_unsupported.go fix(agent): disable seahorse context manager on freebsd/arm (#2417) 2026-04-08 10:57:22 +08:00
context_test.go fix(agent): preserve reused tool call IDs across turns (#2528) 2026-04-15 20:18:09 +08:00
definition.go merge: resolve conflicts between refactor/agent and main 2026-03-22 19:21:58 +08:00
definition_test.go merge: resolve conflicts between refactor/agent and main 2026-03-22 19:21:58 +08:00
dispatch_request.go fix(session): address review regressions 2026-04-13 22:51:44 +08:00
dispatch_request_test.go fix(session): address review regressions 2026-04-13 22:51:44 +08:00
eventbus.go merge: resolve conflicts between refactor/agent and main 2026-03-22 19:21:58 +08:00
eventbus_test.go Merge branch 'main' into refactor-inbound-context-routing-session 2026-04-07 21:41:02 +08:00
events.go Merge branch 'main' into refactor-inbound-context-routing-session 2026-04-07 21:41:02 +08:00
hook_mount.go merge: resolve conflicts between refactor/agent and main 2026-03-22 19:21:58 +08:00
hook_mount_test.go Merge branch 'main' into version 2026-03-23 10:54:08 +08:00
hook_process.go Feat/support isolation (#2423) 2026-04-08 18:15:42 +08:00
hook_process_test.go Feat/support isolation (#2423) 2026-04-08 18:15:42 +08:00
hooks.go merge: integrate main into refactor-inbound-context-routing-session 2026-04-13 13:25:07 +08:00
hooks_test.go refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00
instance.go Feat/support isolation (#2423) 2026-04-08 18:15:42 +08:00
instance_test.go fix: use per candidate provider for model_fallbacks (#2143) 2026-04-07 20:07:56 +08:00
llm_media.go refactor: make agent loop support parallel and update docs 2026-04-16 14:43:15 +08:00
memory.go refactor(modernize): apply safe modernize fixes 2026-02-27 16:35:07 +08:00
mock_provider_test.go feat(fmt): Fix formatting 2026-02-19 22:05:15 +02:00
model_resolution.go feat(model): llm rate limiting (#2198) 2026-04-02 19:26:26 +08:00
pipeline.go refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00
pipeline_execute.go refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00
pipeline_finalize.go refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00
pipeline_llm.go refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00
pipeline_setup.go refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00
registry.go refactor(runtime): drop non-session legacy context compatibility 2026-04-01 20:56:48 +08:00
registry_test.go refactor Config to add Version and migratable 2026-03-12 13:52:55 +08:00
steering.go refactor: make agent loop support parallel and update docs 2026-04-16 14:43:15 +08:00
steering_test.go refactor: make agent loop support parallel and update docs 2026-04-16 14:43:15 +08:00
subturn.go refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00
subturn_test.go Merge branch 'main' into version 2026-03-23 10:54:08 +08:00
thinking.go feat: add extended thinking support for Anthropic models (#1076) 2026-03-05 09:51:18 +08:00
thinking_test.go feat: add extended thinking support for Anthropic models (#1076) 2026-03-05 09:51:18 +08:00
turn_context.go refactor(session): replace dm scope with dimensions policy 2026-04-01 17:19:50 +08:00
turn_coord.go refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00
turn_coord_test.go refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00
turn_state.go refactor(agent): Agent Looper refactor phase2, restructure pipeline and rename loop files to agent (#2585) 2026-04-21 10:55:50 +08:00