thirdeye agent command - #23
Merged
Merged
Conversation
Wraps any AgentAdapter and overrides CLI args for review or fix mode, switching eval adapters from JSON output/restricted tools to text output with mode-appropriate tool access. Unknown adapters fall back to their own config.args unchanged. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Creates src/thirdeye/agent/__init__.py (package marker) and src/thirdeye/agent/prompt.py with build_agent_prompt() that loads shipped skills via importlib.resources, strips YAML frontmatter, and assembles a structured prompt with context block and task. Adds tests/test_agent_prompt.py covering all specified cases. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The join applies to all parts including context and task, so "---" always appears between context and TASK even when no skills are loaded. Replace the incorrect `not in` check with `count == 1`. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements run_agent_streaming in src/thirdeye/agent/exec.py: drives subprocess with Popen for real-time stdout streaming, drains stderr on a background thread to avoid deadlock, and tags any new sessions spawned during the run with 'thirdeye-agent' (best-effort, failures swallowed). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…adjust exit code propagation on success, and add integration/unit tests for session tagging and cwd option
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Context
thirdeye (PyPI:
thrdi) is a Python CLI that hooks into agentic coding tools (Claude Code,Codex, Gemini CLI, Cursor) and records their events into a per-session event store at
~/.thirdeye/traces/<platform>/<session_id>/.This plan adds a new
thirdeye agent "<task>"command — a one-shot agent harness thatinjects thirdeye's shipped skills as context, then invokes a coding agent (Claude Code by
default) to work through the task. The primary use case is session introspection: reviewing
today's sessions, auditing token usage, or identifying inefficiencies. With
--fix, theagent's tool access is broadened to allow file edits so it can apply recommendations.
The command reuses the existing
eval/agents/adapter infrastructure (AgentAdapter,ClaudeAdapter,CodexAdapter,GeminiAdapter,get_adapter()) without modifying it.All new code lives in a new
src/thirdeye/agent/package.After the agent run completes, any new sessions the agent spawned on its platform are
automatically tagged
thirdeye-agent(usingTagStore.add(0, "thirdeye-agent", source="auto")).This lets users filter agent-initiated sessions with
thirdeye list --tag thirdeye-agentandexclude them from general session analysis. Tagging is best-effort — failures are swallowed
so they never block the command.
The four deliverables, spread across three waves:
Key existing modules to understand
src/thirdeye/eval/agents/base.py—AgentAdapterABC,AgentConfigdataclass,ConfigAdapterconcrete implementation.AgentAdapter.build_command(prompt, cwd)returns[command, *resolved_args]with{prompt}substituted.src/thirdeye/eval/agents/__init__.py—get_adapter(name, thirdeye_home)returnsan adapter instance;
list_agent_names(thirdeye_home)returns sorted list of availablenames (builtins + user YAML overrides).
src/thirdeye/eval/agents/claude.py—ClaudeAdapterusesclaude -p {prompt} --output-format json --allowedTools "Bash(thirdeye *) ...". Theharness overrides these args for agent mode (text output, mode-appropriate tools).
src/thirdeye/web/agentic.py— reference for theimportlib.resourcespattern forloading shipped skills and stripping YAML frontmatter. Study
_read_skill_body()and_FRONTMATTER_RE.src/thirdeye/config.py—Config.load()readsTHIRDEYE_HOMEenv var or defaultsto
~/.thirdeye.Shipped skills (all under
src/thirdeye/skills/<name>/SKILL.md):use-thirdeye— how to use the thirdeye CLI to retrieve and inspect sessionsthirdeye-review— five-step workflow for auditing agent sessions for inefficienciesthirdeye-evals— how to run and interpret session evaluationsthirdeye-filter— NL-to-filter skill (used by the web UI; not typically needed here)Tasks
🤖 Reviewed by workbench. Report:
.workbench/agent-command/wrap-up/agent-command/review.md