summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorKit Langton <[email protected]>2026-04-15 10:49:47 -0400
committerGitHub <[email protected]>2026-04-15 10:49:47 -0400
commit685d79e953a02a3a78b91235c811932105574a66 (patch)
tree93e724aeb2bcee68bd283cb83d03555a10f5533c
parentbe9432a893dd1662c10ff41c7ab552bcba8f3e1b (diff)
downloadopencode-685d79e953a02a3a78b91235c811932105574a66.tar.gz
opencode-685d79e953a02a3a78b91235c811932105574a66.zip
feat(opencode): trace tool execution spans (#22531)
-rw-r--r--packages/opencode/src/tool/tool.ts13
1 files changed, 10 insertions, 3 deletions
diff --git a/packages/opencode/src/tool/tool.ts b/packages/opencode/src/tool/tool.ts
index 49dd2b060..30be63a32 100644
--- a/packages/opencode/src/tool/tool.ts
+++ b/packages/opencode/src/tool/tool.ts
@@ -80,8 +80,14 @@ export namespace Tool {
Effect.gen(function* () {
const toolInfo = init instanceof Function ? { ...(yield* init()) } : { ...init }
const execute = toolInfo.execute
- toolInfo.execute = (args, ctx) =>
- Effect.gen(function* () {
+ toolInfo.execute = (args, ctx) => {
+ const attrs = {
+ "tool.name": id,
+ "session.id": ctx.sessionID,
+ "message.id": ctx.messageID,
+ ...(ctx.callID ? { "tool.call_id": ctx.callID } : {}),
+ }
+ return Effect.gen(function* () {
yield* Effect.try({
try: () => toolInfo.parameters.parse(args),
catch: (error) => {
@@ -109,7 +115,8 @@ export namespace Tool {
...(truncated.truncated && { outputPath: truncated.outputPath }),
},
}
- }).pipe(Effect.orDie)
+ }).pipe(Effect.orDie, Effect.withSpan("Tool.execute", { attributes: attrs }))
+ }
return toolInfo
})
}