Skip to content

Commit 46d0d2e

Browse files
ZhiXiao-Linclaude
andcommitted
fix: replace #[tracing::instrument] with manual tracing events
tracing 0.1.41+ introduced PhantomNotSend in Span, making futures produced by #[tracing::instrument] !Send. This breaks tokio::spawn and JoinSet::spawn call sites. Replace the proc macro attribute on execute_with_session with explicit tracing::info/warn calls that don't hold a Span across .await boundaries. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2fc764e commit 46d0d2e

3 files changed

Lines changed: 27 additions & 17 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ anyhow = "1.0"
3939
thiserror = "1.0"
4040

4141
# Logging (tracing only — no OTel)
42-
tracing = ">=0.1, <0.1.41"
42+
tracing = "0.1"
4343
tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }
4444

4545
# Async utilities

core/src/agent.rs

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -861,30 +861,40 @@ impl AgentLoop {
861861
///
862862
/// Takes the conversation history, user prompt, and optional session ID.
863863
/// When session_id is provided, context providers can use it for session-specific context.
864-
#[tracing::instrument(
865-
name = "a3s.agent.execute",
866-
skip(self, history, prompt, event_tx),
867-
fields(
868-
a3s.session.id = session_id.unwrap_or("none"),
869-
a3s.agent.max_turns = self.config.max_tool_rounds,
870-
a3s.agent.tool_calls_count = tracing::field::Empty,
871-
a3s.llm.total_tokens = tracing::field::Empty,
872-
)
873-
)]
874864
pub async fn execute_with_session(
875865
&self,
876866
history: &[Message],
877867
prompt: &str,
878868
session_id: Option<&str>,
879869
event_tx: Option<mpsc::Sender<AgentEvent>>,
880870
) -> Result<AgentResult> {
871+
tracing::info!(
872+
a3s.session.id = session_id.unwrap_or("none"),
873+
a3s.agent.max_turns = self.config.max_tool_rounds,
874+
"a3s.agent.execute started"
875+
);
876+
881877
// Route to planning-based execution if enabled
882-
if self.config.planning_enabled {
883-
return self.execute_with_planning(history, prompt, event_tx).await;
878+
let result = if self.config.planning_enabled {
879+
self.execute_with_planning(history, prompt, event_tx).await
880+
} else {
881+
self.execute_loop(history, prompt, session_id, event_tx)
882+
.await
883+
};
884+
885+
match &result {
886+
Ok(r) => tracing::info!(
887+
a3s.agent.tool_calls_count = r.tool_calls_count,
888+
a3s.llm.total_tokens = r.usage.total_tokens,
889+
"a3s.agent.execute completed"
890+
),
891+
Err(e) => tracing::warn!(
892+
error = %e,
893+
"a3s.agent.execute failed"
894+
),
884895
}
885896

886-
self.execute_loop(history, prompt, session_id, event_tx)
887-
.await
897+
result
888898
}
889899

890900
/// Core execution loop (without planning routing).

0 commit comments

Comments
 (0)