# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.7.0] - 2026-03-25

### Added
- Interactive control channel via `AgentOp` and `AgentLoop::run_with_ops()`.
- New loop events: `Interrupted`, `AskUser`, and `AskUserTimeout`.
- Mid-turn operations:
  - `AgentOp::Interrupt`
  - `AgentOp::InjectUserMessage`
  - `AgentOp::InjectHint`
  - `AgentOp::AskUserAnswer { call_id: Option<String>, answer }`
- Built-in `ask_user` tool registration on the builder:
  - `with_ask_user()`
  - `with_ask_user_timeout(Duration)`
- `AgentSession` for long-lived background sessions with managed history.
- Session persistence primitives:
  - `SessionStore` trait
  - `MemorySessionStore`
  - `FileSessionStore` (JSONL with `SessionMeta`, buffered append + flush)
- New integration tests for interactive ops and session/store behaviors.

### Changed
- Extract tool execution policy into dedicated module for cleaner `run_with_ops` internals.

### Fixed
- Avoid session persistence duplicates and reset race condition.

## [0.6.0] - 2026-03-25

### Added
- Live Anthropic integration tests for `AgentLoop` (gated behind API key).

### Changed
- Version bump to prepare for v0.7.0 interactive features.

## [0.5.0] - 2026-03-24

_Skipped — internal development version, never published to crates.io._

## [0.4.0] - 2026-03-24

### Added
- **MCP support** — first-class Model Context Protocol integration.
  - `McpServer` trait + `McpServerStdio` + `McpServerHttp` types (#33).
  - `McpToolAdapter` — wrap `McpServer` tools as `Arc<dyn Tool>` (#34).
  - `AgentLoopBuilder::mcp_server()` for owned MCP servers (#35).
  - `AgentLoopBuilder::mcp_server_arc()` for shared `Arc<dyn McpServer>` (#43).
  - Auto connect/disconnect MCP servers in `run_streaming()` (#39).
- `CancellationToken` support for `AgentLoop::run()` via `cancellation` feature gate (#54).
- Per-tool call timeout via `AgentLoopBuilder::tool_timeout()` (#51).
- `AgentResult` now includes final `messages: Vec<Message>` for conversation replay (#53).
- Context providers now run in parallel with `try_join_all` (#41).

### Changed
- Cache `tool_map` and `tool_defs` in `AgentLoop` — avoids rebuilding on every `run()` (#52).
- Extract `prepare_messages()` to eliminate `run`/`run_streaming` duplication (#40).
- Remove confusing `extra_tools` → `mcp_tools` alias in `run_inner` (#42).

### Fixed
- MCP partial connect failure now disconnects already-connected servers before returning error (#50).

## [0.3.0] - 2026-03-24

### Added
- Streaming support — `run_streaming()` with `AgentEvent::TextChunk` via `on_event` callback (#19).
- `LlmClient::chat_stream()` with default fallback to `chat()` (#21).
- `ChatOutput` wrapper with `LlmResponse` + optional `TokenUsage` (#24).
- `AgentLoopBuilder::system_prompt()` shortcut (#23).
- `TokenUsage` tracking in `AgentResult` (#24).
- `motosan-ai` feature gate with `LlmClient` bridge for motosan-ai SDK.
- CI and publish GitHub Actions workflows.

### Changed
- `LlmClient::chat()` now returns `ChatOutput` instead of `LlmResponse` (breaking).
- `LlmClient::chat()` takes `&[Message]` instead of `Vec<Message>` (breaking).
- API cleanup: collapse `ToolCall`, add `args` to `ToolCallRef`, borrow messages (#13-#15).

### Fixed
- Emit `AgentEvent::IterationStarted` in `run()` for consistency with `run_streaming()` (#22).

## [0.2.0] - 2026-03-23

### Added
- `motosan-ai` feature gate with `LlmClient` bridge for motosan-ai SDK.
- CI (`ci.yml`) and publish (`publish.yml`) GitHub Actions workflows.

### Changed
- API cleanup before publish: collapse `ToolCall`, add `args` to `ToolCallRef`, borrow messages (#13-#15).

## [0.1.0] - 2026-03-23

### Added

- `LlmClient` trait with async `chat()` method for pluggable LLM backends.
- `LlmResponse` enum (`Message`, `ToolCall`, `ToolCalls`) for structured LLM output.
- `ToolCallItem` struct for batched tool call payloads.
- `Message` type with role-specific constructors (`system`, `user`, `assistant`, `tool_result`).
- `ToolCallRef` for correlating assistant tool-call requests with tool results.
- `AgentLoop` -- the core ReAct loop driving iterative reasoning and tool execution.
- Single and parallel tool execution support via `futures::join_all`.
- `AgentEvent` enum (`ToolStarted`, `ToolCompleted`, `TextChunk`) for observability callbacks.
- `AgentResult` containing the final answer, tool-call history, and iteration count.
- `AgentLoopBuilder` with `tool()`, `tools()`, `context()`, `contexts()`, and `max_iterations()`.
- `ContextProvider` trait for injecting dynamic system context (RAG docs, user profiles, etc.).
- `AgentError` / `Result` with variants for LLM errors, tool errors, serde errors, and max-iteration limits.
