anomalyco / anomalyco/opencode
[FEATURE]: task tool results should carry child-session duration and token metrics
@jlongster is already working on this.
Since Sep 7, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Task tool returns the final text plus child sessionID/model in the tool-part metadata (task.ts:185-190), but no duration, token, or cost figures. The child session row already has everything at return time (sessions table: time_created/time_updated/cost/tokens_*, packages/core/src/session/sql.ts:43-48).
Proposed change
In task.ts (dev@57ef382843, foreground 341-345 + background inject 227-242): append durationMs + tokens (and cost if >0) to metadata and/or one recap line in the output. Requires an extra sessions.get(nextSession.id) (background.wait return info carries no tokens), so ~10 lines is the low end; single site, extend existing task.test.ts.
Use case
Multi-agent delegation observability: watchdogs, cost and budget tracking, per-subagent timing — without an extra DB query from the caller.
Environment
opencode v1.18.29, Linux.
Searched "task metrics", "subagent duration" — no open issue. Complements closed #6354 and #22959 (UI-level timing; this is tool-level).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.