Repository navigation
Add live agent session viewer and recorded context #855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+4,933
−411
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
769892f
fix(agents2): keep agents running when another community is selected
9011eb8
fix(agents2): retry a failed unselected community connection
cb99f1c
perf(claude-code): one shared spare process instead of one per agent
baxen c06f6b5
fix(claude-code): only the runtime decides where a spare is kept
baxen 10ddcc8
fix(agents2): end agent lifetimes on teardown and inventory errors
baxen fafa5d6
perf(codex): one app-server for every agent
baxen da93663
[session-debug] live agent session viewer
baxen a7a305e
[session-debug-context] show recorded prompt, tools and injected context
baxen 430392d
fix(session-debug): let Vite's dependency scan resolve the inspector …
baxen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| # Inspect a live agent session | ||
|
|
||
| From a buzz-app checkout: | ||
|
|
||
| ```sh | ||
| bin/node scripts/session-debug.mjs '<thread-id or buzz://message link>' | ||
| ``` | ||
|
|
||
| The command opens a private loopback URL in your browser and follows Codex or | ||
| Claude JSONL records once a second. Leave the command running. Ctrl+C stops it. | ||
| It does not resume an agent, execute transcript content, or send data to a relay. | ||
| For a known file use `--file /absolute/session.jsonl`. `--no-open` prints the URL | ||
| without opening it. A partial last JSONL line is retried on the next refresh; | ||
| malformed complete records produce a visible error, not silent omission. | ||
|
|
||
| The left rail is one vertical wall-time chart for the whole session, with time | ||
| running downward. Active time is proportional: inference, tools, inference | ||
| overlapping a tool, and **unattributed** gaps (a run is active but no model or | ||
| tool activity is recorded). **Idle** time between runs, when the agent waits for | ||
| the next prompt, collapses to a labeled break. The legend totals each category; | ||
| overlap is counted once, never added to wall time. Tool time is call-to-result | ||
| elapsed time, not subprocess CPU time. Beside each inference, a thin mark shows | ||
| its new (uncached) tokens; hover it for the full context window and cache share. | ||
| Hover or focus a bar segment for its timing and tool names; click either to jump | ||
| the conversation to that record. | ||
|
|
||
| Native transcripts do not expose exact provider request start times. Inference | ||
| bars are explicitly estimated from the preceding logged input/result through | ||
| observed model output, and can include queue, prefill and dispatch overhead. With | ||
| no usable output boundary, the chart shows an untimed inference and leaves that | ||
| time unattributed. An explicit running turn extends to now; legacy sessions with | ||
| no completion record end at their last recorded message. Claude Code's zero-usage | ||
| `<synthetic>` replies and queue bookkeeping are not counted as activity. The chart | ||
| uses UTC to match the transcript timestamps. | ||
|
|
||
| Each inference shows new-input, cache-read, cache-write (when nonzero), and output | ||
| tokens. Token counts are the default cost view. Optional dollar estimates appear | ||
| only when rates are supplied; missing prices do not produce placeholder warnings. | ||
| For Codex, cached tokens are part of input and are subtracted to find new input. | ||
| Claude already reports new input separately. Neither provider's cache usage is | ||
| counted twice. | ||
|
|
||
| The conversation stays on the right, under one line naming the harness, model | ||
| and reasoning effort (when the transcript records it). Messages the agent posted | ||
| to Buzz are highlighted; plain assistant text was never sent. Search filters the | ||
| conversation. The view follows new records while it is scrolled to the bottom | ||
| and leaves your position alone otherwise; expanded disclosures survive updates. | ||
| These are recorded transcript views, not exact reconstructed HTTP inference | ||
| requests. When multiple sessions match a thread, only one is shown; open a | ||
| specific one with `--file`. Thread discovery checks user delivery envelopes, | ||
| rather than matches in tool outputs that merely quoted a thread. Channel-scoped | ||
| sessions and DMs may require `--file`, and can contain multiple Buzz threads. | ||
|
|
||
| ## Recorded fields and cost | ||
|
|
||
| **Prompt** opens what the model received before its first response. Instructions | ||
| are tagged with the role they were sent as (System, Developer, User, or Settings | ||
| for run configuration) and render as Markdown: the system prompt first, then | ||
| the rest in recorded order. Tools show one row per tool, opening to its | ||
| description and JSON schema. Context injected later, such as Claude Code's | ||
| reminders, stays in the conversation as faint rows. | ||
|
|
||
| Codex supplies `session_meta.base_instructions`, `dynamic_tools`, developer/user | ||
| messages, response items, lifecycle events, and token usage when supported by its | ||
| CLI version. Run settings (approval, sandbox, collaboration mode, effort) come from | ||
| `turn_context` and show again when they change. Codex does not record its native | ||
| tool schemas, such as shell and apply_patch. The viewer prefers per-response `token_usage_record`, deduplicates | ||
| response IDs, and falls back to changes in cumulative token counts. It does not | ||
| add those two sources together. The chart uses timestamp intervals to account for | ||
| wall time; recorded `duration_ms` remains available in raw records. | ||
|
|
||
| Claude's native transcript supplies messages and usage. Claude Code also writes a | ||
| `prompt_snapshot` with the system prompt and tool schemas, shown once per change, | ||
| and the rendered text and role of each reminder it injects (environment, skills, | ||
| CLAUDE.md, hook context). Request framing, such as billing and SDK system blocks, | ||
| beta headers and deferred tool schemas, is not recorded. Content blocks can repeat | ||
| the same message ID and usage; the viewer counts each response once. Legacy turn | ||
| boundaries are inferred from user messages; tool results do not start turns. | ||
| Without a completion event the viewer does not pretend that the last token's | ||
| arrival proves completion. Inferred boundaries are labeled. | ||
|
|
||
| Dollar costs are unavailable unless reported or a rate file is supplied. They are | ||
| never represented as zero merely because the account uses a subscription. Claude | ||
| result totals are process-cumulative; the viewer derives differences within each | ||
| captured launch and labels the result. Exact billing can differ from API estimates. | ||
|
|
||
| To estimate costs, create a JSON object keyed by exact model ID with USD per | ||
| million token rates, then pass `--rates /path/to/rates.json`: | ||
|
|
||
| ```json | ||
| {"your-model-id":{"input":2,"output":10,"cached":0.2,"written":2.5}} | ||
| ``` | ||
|
|
||
| These are illustrative rates, not current pricing. Supply all four rates. No | ||
| models or prices are guessed. The UI labels estimates. For Claude, input excludes | ||
| cache reads and writes; for Codex those are subtracted from inclusive input before | ||
| pricing. Models with tiered context, service tiers, or cache TTL pricing need rates | ||
| appropriate to the inspected usage; the simple estimator does not infer tiers. | ||
|
|
||
| ## Storage and older exports | ||
|
|
||
| Discovery reads `$CODEX_HOME/sessions`, `$CODEX_HOME/archived_sessions` (default | ||
| `~/.codex`) and `$CLAUDE_CONFIG_DIR/projects` (default `~/.claude`). Compressed | ||
| `.jsonl.zst` rollouts must be decompressed to a local file first and opened with | ||
| `--file`. The server is bound to 127.0.0.1, uses an unguessable path, rejects foreign | ||
| Host/Origin requests, and serves only its three assets and selected transcript. | ||
|
|
||
| For standalone snapshots, the existing | ||
| [Codex](view-codex-session.md) and [Claude](view-claude-session.md) exporters remain | ||
| available. A snapshot does not update. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Confirm Claude delivery before rendering a send as posted
This branch replaces every
buzz__sendinvocation with a “posted to Buzz” card without consulting theresultsmap. If publication is rejected, the recordedtool_result.is_errorand its explanation are therefore discarded; a still-pending send is also shown as delivered. That makes the diagnostic viewer report success precisely when someone is investigating a missing reply. Preserve the pending/failed tool row and show a posted card only when the recorded result confirms success. The analogous Codex-side issue is already covered in this finding.