diff --git a/src/agent/api/mod.rs b/src/agent/api/mod.rs
index 9d398fc..169f8e4 100644
--- a/src/agent/api/mod.rs
+++ b/src/agent/api/mod.rs
@@ -6,6 +6,7 @@
// Diagnostics: anomalies always logged to debug panel.
// Set POC_DEBUG=1 for verbose per-turn logging.
+pub mod parsing;
pub mod types;
mod openai;
@@ -17,7 +18,8 @@ use std::time::{Duration, Instant};
use tokio::sync::mpsc;
-use crate::agent::tools::{self as agent_tools, ToolCall, FunctionCall};
+use crate::agent::tools::{self as agent_tools};
+use types::{ToolCall, FunctionCall};
use crate::user::ui_channel::{UiMessage, UiSender};
/// A JoinHandle that aborts its task when dropped.
@@ -488,9 +490,9 @@ pub fn build_response_message(
}
// Check for leaked tool calls in content text.
- let leaked = crate::agent::parsing::parse_leaked_tool_calls(&content);
+ let leaked = parsing::parse_leaked_tool_calls(&content);
if !leaked.is_empty() {
- let cleaned = crate::agent::parsing::strip_leaked_artifacts(&content);
+ let cleaned = parsing::strip_leaked_artifacts(&content);
return Message {
role: Role::Assistant,
content: if cleaned.trim().is_empty() { None }
diff --git a/src/agent/parsing.rs b/src/agent/api/parsing.rs
similarity index 99%
rename from src/agent/parsing.rs
rename to src/agent/api/parsing.rs
index a5f5ce1..2658aa5 100644
--- a/src/agent/parsing.rs
+++ b/src/agent/api/parsing.rs
@@ -11,7 +11,7 @@
// Also handles streaming artifacts: whitespace inside XML tags from
// token boundaries, tags, etc.
-use crate::agent::tools::{ToolCall, FunctionCall};
+use super::types::{ToolCall, FunctionCall};
/// Parse leaked tool calls from response text.
/// Looks for `...` blocks and tries both
diff --git a/src/agent/api/types.rs b/src/agent/api/types.rs
index ed80303..7989c2f 100644
--- a/src/agent/api/types.rs
+++ b/src/agent/api/types.rs
@@ -9,7 +9,38 @@
use chrono::Utc;
use serde::{Deserialize, Serialize};
-use crate::agent::tools::{ToolCall, ToolCallDelta};
+/// Function call within a tool call — name + JSON arguments.
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct FunctionCall {
+ pub name: String,
+ pub arguments: String,
+}
+
+/// Partial function call within a streaming delta.
+#[derive(Debug, Deserialize)]
+pub struct FunctionCallDelta {
+ pub name: Option,
+ pub arguments: Option,
+}
+
+/// A tool call requested by the model.
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct ToolCall {
+ pub id: String,
+ #[serde(rename = "type")]
+ pub call_type: String,
+ pub function: FunctionCall,
+}
+
+/// A partial tool call within a streaming delta.
+#[derive(Debug, Deserialize)]
+pub struct ToolCallDelta {
+ pub index: usize,
+ pub id: Option,
+ #[serde(rename = "type")]
+ pub call_type: Option,
+ pub function: Option,
+}
/// Message content — either plain text or an array of content parts
/// (for multimodal messages with images). Serializes as a JSON string
diff --git a/src/agent/mod.rs b/src/agent/mod.rs
index 0986a4f..33a2738 100644
--- a/src/agent/mod.rs
+++ b/src/agent/mod.rs
@@ -16,7 +16,6 @@
pub mod api;
pub mod context;
pub mod oneshot;
-pub mod parsing;
pub mod tools;
pub mod training;
@@ -340,7 +339,7 @@ impl Agent {
tool_call_buf.push_str(&text);
if let Some(end) = tool_call_buf.find("") {
let body = &tool_call_buf[..end];
- if let Some(call) = crate::agent::parsing::parse_tool_call_body(body) {
+ if let Some(call) = crate::agent::api::parsing::parse_tool_call_body(body) {
let args: serde_json::Value =
serde_json::from_str(&call.function.arguments).unwrap_or_default();
let args_summary = summarize_args(&call.function.name, &args);
diff --git a/src/agent/tools/mod.rs b/src/agent/tools/mod.rs
index 75f7f1e..041ab45 100644
--- a/src/agent/tools/mod.rs
+++ b/src/agent/tools/mod.rs
@@ -20,7 +20,6 @@ mod control;
mod vision;
pub mod working_stack;
-use serde::{Serialize, Deserialize};
use std::future::Future;
use std::pin::Pin;
use std::time::Instant;
@@ -57,40 +56,8 @@ impl Tool {
}
}
-/// Function call within a tool call — name + JSON arguments.
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct FunctionCall {
- pub name: String,
- pub arguments: String,
-}
-
-/// Partial function call within a streaming delta.
-#[derive(Debug, Deserialize)]
-pub struct FunctionCallDelta {
- pub name: Option,
- pub arguments: Option,
-}
-
-/// A tool call requested by the model.
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct ToolCall {
- pub id: String,
- #[serde(rename = "type")]
- pub call_type: String,
- pub function: FunctionCall,
-}
-
-/// A partial tool call within a streaming delta. The first chunk for a
-/// given tool call carries the id and function name; subsequent chunks
-/// carry argument fragments.
-#[derive(Debug, Deserialize)]
-pub struct ToolCallDelta {
- pub index: usize,
- pub id: Option,
- #[serde(rename = "type")]
- pub call_type: Option,
- pub function: Option,
-}
+// Re-export API wire types used by the agent turn loop
+pub use super::api::types::{FunctionCall, ToolCall, ToolCallDelta};
/// A tool call in flight — metadata for TUI + JoinHandle for
/// result collection and cancellation.