Skip to content

tozzi21/opencode-runtime-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

OpenCode Runtime Analyzer

A standalone utility that reconstructs actual autonomous runtime from an OpenCode session by analysing the local OpenCode SQLite database.

Unlike wall-clock duration, this tool reports active compute time by measuring when agents and tools were actually executing, automatically excluding:

  • Waiting for user input
  • Overnight idle time
  • Paused or resumed OpenCode sessions

It also understands Superpowers Subagent-Driven Development (SDD) projects and reports implementation progress from your execution ledger.


Motivation

Large OpenCode + Superpowers projects can run for days. A typical project might occupy three calendar days while only consuming ten hours of actual autonomous work.

This tool answers questions such as:

  • How many hours did OpenCode actually work?
  • How much time was spent inside LLMs?
  • Which tools consumed the most runtime?
  • Which models were used?
  • How many subagents participated?
  • How far through the implementation plan are we?

Features

  • Reads the local OpenCode SQLite database (opencode.db)
  • Supports resumed sessions
  • Supports parent agents and spawned subagents
  • Calculates active runtime without counting idle periods
  • Merges overlapping agent execution
  • Reports aggregate agent-seconds
  • Summarises tool runtime
  • Reports model usage
  • Detects Superpowers implementation plans
  • Calculates SDD programme progress

Example Output

══════════════════════════════════════════════════════
OpenCode Runtime Report

Repository:	case-management-platform
Sessions:   39 (38 subagent sessions)
From:       2026-07-18T14:15:51.829000+00:00
To:         2026-07-25T14:15:15.191000+00:00

Wall clock					2d 17h 14m
Idle/off time excluded		2d 05h 49m
──────────────────────────────────────────────────────
Active compute				11h 25m
Aggregate agent runtime		18h 41m
Utilisation					16.2%

Recorded Runtime by Category
tool                               4d 20h 33m 18s
agent-turn                         4d 04h 18m 46s
thinking                              19h 27m 25s
generation                             2h 16m 16s

Tool Runtime
task                               4d 18h 50m 12s
read                                      38m 02s
bash                                      36m 39s
question                                  14m 09s
grep                                       8m 58s
apply_patch                                3m 17s
glob                                       1m 35s
skill                                         22s
write                                          2s
edit                                           1s
todowrite                                      0s

Model Calls / Assistant Messages
openai / gpt-5.6-sol                         8488
kimi-for-coding / k3                          417

Programme Progress
F1–F6      6 tasks
I1–I5      5 tasks
P1–P6      6 tasks
L1–L6      6 tasks
A1–A5      5 tasks
N1–N5      5 tasks
──────────────────────────────────────────────────────────────────
Completed from progress.md   11 / 33 (33.3%)

Longest Sessions
4d 21h 14m 15s  parent    ses_08a6a9f17ffeiDlAtfkgy4ndnA
   20h 22m 59s  subagent  ses_075c15dceffecGiav2wSCGX4Tq
   16h 57m 54s  subagent  ses_06d8556c0ffe9xDrycvfh7RWbr
   10h 30m 07s  subagent  ses_0786f938cffevzPuenNsb7DRJA
    9h 27m 13s  subagent  ses_07d65c9a1ffefGFTcVh1XSskvy
    5h 38m 22s  subagent  ses_07b1ce3efffemoIt6dRdV95n7Y
    5h 03m 50s  subagent  ses_079bb58b4ffeeQDHWeRyUX9hsk
    3h 31m 46s  subagent  ses_06e89be43ffeATQV9lmezH5PF2
    2h 22m 35s  subagent  ses_066ff8464ffevqfizfqI2GQbkw
    1h 22m 20s  subagent  ses_07544b9d9ffe3SqHztm4IbIcKn
    1h 09m 25s  subagent  ses_08557f5f9ffeCHEGkucePW83ja
    1h 05m 38s  subagent  ses_084b7633bffexLNaI1eE5SqkB7
    1h 02m 54s  subagent  ses_07d35872effeY3IwPFqg5SPQbY
    1h 01m 59s  subagent  ses_06cb20c17ffe1AWGbY4GJE0CRG
       54m 50s  subagent  ses_07847f540ffesj0TW7DHSXCEUW
	   
* Active elapsed merges concurrent agent/tool intervals, so parallel work is counted once.
* Aggregate recorded time sums intervals, so parallel agents count separately.
* Tool time may overlap agent-turn time and is therefore not additive with it.
* Agent-turn spans longer than --idle-threshold are capped when finer part timing is unavailable.
══════════════════════════════════════════════════════════════════

Requirements

  • Python 3.10+
  • OpenCode
  • Local OpenCode SQLite database

The script expects the default database location:

~/.local/share/opencode/opencode.db

Usage

Analyse a project:

python opencode-runtime.py \
    /path/to/worktree

Optional Arguments

JSON Output

--json

Limit to a session

--session ses_066ff8464ffevqfizfqI2GQbkw

Verbose Mode

--verbose

Idle Threshold

Some OpenCode versions persist only assistant start/end timestamps. The fallback idle threshold limits how much silent time inside a single assistant turn is counted when no finer-grained timing exists.

Default:

300 seconds

Override:

./opencode-runtime.py \
    /path/to/worktree \
    --idle-threshold 120

How It Works

The analyser creates a read-only backup of the OpenCode SQLite database before processing.

It reconstructs execution using persisted timing information from:

  • Sessions
  • Messages
  • Assistant parts
  • Tool parts

Rather than simply subtracting the first timestamp from the last, it builds execution intervals and merges overlapping work.

This allows multiple concurrent subagents to contribute only once to Active Compute, while also reporting their combined runtime separately as Aggregate Agent Runtime.


Superpowers Support

When a project contains:

docs/superpowers/plans/

and

.superpowers/sdd/

the analyser automatically reports programme progress.

For example:

Foundation      6 / 6
Ingestion       4 / 5
Physical        0 / 6
Postings        0 / 6
Accounting      0 / 5

This makes it easy to understand overall progress through large Subagent-Driven Development (SDD) programmes.


Definitions

Wall Clock

Elapsed real-world time between the first and last recorded activity.

Includes overnight pauses and crashes.


Active Compute

Elapsed time during which one or more agents or tools were actively executing.

Concurrent agents count only once.


Aggregate Agent Runtime

Sum of all recorded agent runtime.

If two subagents execute simultaneously for ten minutes, aggregate runtime increases by twenty minutes.


Utilisation

Active Compute
──────────────
Wall Clock

Expressed as a percentage.


Limitations

The analyser depends on timing information persisted by OpenCode.

If a particular OpenCode version omits timestamps for specific events, those intervals cannot be reconstructed exactly.

Future OpenCode releases may introduce schema changes requiring updates to the parser.


Future Improvements

  • Interactive HTML dashboard
  • Per-model cost estimation
  • Cost per implementation task
  • Runtime by Git branch
  • Runtime by tool category
  • Timeline visualisation
  • Gantt chart of subagent execution
  • Flame graph of concurrent agents
  • CSV export
  • Prometheus metrics

Contributing

If you encounter an OpenCode schema that is not yet supported, please include:

  • OpenCode version
  • SQLite schema (.schema)
  • Sanitised example rows

so support can be added without exposing sensitive project data.


Acknowledgements

This project was inspired by the excellent work on OpenCode, and Superpowers by Obra Software.


License

MIT

About

Analyse autonomous AI software engineering sessions performed with OpenCode and Superpowers, providing accurate measurement of active compute time, subagent utilisation, and programme progress for large-scale Subagent-Driven Development (SDD) initiatives

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages