feat: add tape recording system for workspace analyze sessions#30
feat: add tape recording system for workspace analyze sessions#30
Conversation
Implement a Go port of republic's tape system that records agent execution as append-only JSONL entries. Each workspace analyze run generates a .tape.jsonl file capturing messages, tool calls, results, errors, and events with token usage metadata. - pkg/tape: entry model, JSONL store, eino callback handler, slog handler - Integrate JSONL tape recorder in analyzer via Config.TapePath - Register slog tape handler globally in main.go for live logging
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 311196d385
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if config.TapePath != "" { | ||
| jsonlStore := tape.NewJSONLStore(config.TapePath) | ||
| callbacks.AppendGlobalHandlers(tape.NewHandler(jsonlStore)) | ||
| slog.Info("Tape recording enabled", "path", config.TapePath) |
There was a problem hiding this comment.
Avoid appending tape callbacks to global handler state
RunAgentWithPrompt installs a new tape callback via callbacks.AppendGlobalHandlers on every invocation, but global handlers are process-wide and never removed. If this function is called more than once in a process (e.g., repeated analyzer runs in tests or embedded usage), later runs will invoke all previously registered tape handlers, causing duplicated events and writes to stale tape files from earlier sessions.
Useful? React with 👍 / 👎.
| func NewJSONLStore(path string) *JSONLStore { | ||
| return &JSONLStore{ | ||
| path: path, | ||
| nextID: 1, |
There was a problem hiding this comment.
Preserve unique entry IDs when appending to existing tape
The store always starts nextID at 1, but writes are append-only, so rerunning workspace analyze against an existing .tape.jsonl file creates duplicate IDs in the same tape. Any consumer that relies on Entry.ID uniqueness or monotonic ordering will get ambiguous records after the first rerun.
Useful? React with 👍 / 👎.
Implement a Go port of republic's tape system that records agent
execution as append-only JSONL entries. Each workspace analyze run
generates a .tape.jsonl file capturing messages, tool calls, results,
errors, and events with token usage metadata.