Skip to content

feat: expose bounded thread usage lineage telemetry - #527

Closed
GraciousGazelles wants to merge 13 commits into
mainfrom
agent/agent-tree-usage-telemetry
Closed

GraciousGazelles wants to merge 13 commits into
mainfrom
agent/agent-tree-usage-telemetry

Conversation

@GraciousGazelles

@GraciousGazelles GraciousGazelles commented Jul 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary:

  • Persist explicit lineage edge kind and concrete spawn request ID for usage threads.
  • Expose experimental thread/usageSummary for one root-family token and credit snapshot.
  • Keep continuation advice read-only and eligible only for direct user threads.

Validation:

  • cargo fmt --all -- --check (run from codex-rs)
  • git diff --check

Hosted validation is required for Rust compilation, generated protocol artifacts, and integration coverage.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an experimental thread/usageSummary endpoint to provide read-only lineage and usage telemetry for persisted thread families. The changes include new protocol definitions, database schema updates to track lineage, and logic for aggregating token and credit usage. The review feedback identifies a performance optimization for a SQL query to avoid full table scans, a fix for correctly aggregating the partial status in usage totals, and a suggestion for more idiomatic credit estimation logic.

Comment thread codex-rs/state/src/runtime/usage.rs Resolved
@GraciousGazelles

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the experimental thread/usageSummary endpoint to retrieve read-only lineage and usage telemetry for a persisted thread family. It adds the necessary protocol definitions, request/response structs, message processing, and state runtime logic to query the local SQLite database, along with a database migration to track lineage_edge_kind and spawn_request_id directly on threads. Feedback was provided regarding a performance issue in the SQL query within get_usage_lineage_telemetry, where the CTEs perform full table scans and aggregations before filtering. The reviewer suggested introducing a family_threads CTE to filter the relevant thread IDs first, allowing SQLite to utilize indexes and avoid scanning entire tables.

Comment thread codex-rs/state/src/runtime/usage.rs Resolved
@GraciousGazelles
GraciousGazelles marked this pull request as ready for review July 28, 2026 07:46
@GraciousGazelles
GraciousGazelles force-pushed the agent/agent-tree-usage-telemetry branch 2 times, most recently from 73ddc12 to 3ac14ca Compare July 28, 2026 08:05
@GraciousGazelles
GraciousGazelles force-pushed the agent/agent-tree-usage-telemetry branch from 051220e to 6b505cc Compare July 28, 2026 17:10
@GraciousGazelles
GraciousGazelles enabled auto-merge (squash) July 29, 2026 04:58
@GraciousGazelles

Copy link
Copy Markdown
Collaborator Author

Superseded by #547, the signed usage-lineage replacement; #547 has merged through the native queue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant