Skip to content

Feat(agents): Document adapter extensibility, add Claude adapter cost tracking - #13

Closed
karthickmk2001 wants to merge 3 commits into
secfoo-com:mainfrom
karthickmk2001:feature/secfoo-agent-cost-tracking
Closed

karthickmk2001 wants to merge 3 commits into
secfoo-com:mainfrom
karthickmk2001:feature/secfoo-agent-cost-tracking

Conversation

@karthickmk2001

@karthickmk2001 karthickmk2001 commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Documents how to add or change an agent adapter (AgentAdapter, the ADAPTERS registry, and the optional extract_report()/extract_cost() hooks) in CONTRIBUTING.md, with a pointer from README's "Bring your own agent" bullet.
  • Extends AI spend tracking (secfoo cost) beyond the built-in secfoo/LangGraph agent: adds an extract_cost() hook to AgentAdapter and wires it up for the claude adapter using Claude Code's own total_cost_usd field from --output-format json.
  • Cursor, Antigravity, and Gemini CLI adapters intentionally leave cost unset (documented inline) since those CLIs don't report a spend figure themselves. No token-count estimation was added, since there's no pricing table in this repo to keep current.
  • README/CONTRIBUTING.md updated to state the real cost-tracking coverage instead of the previous vague "spend is stored per run" phrasing.

Test plan

  • pytest tests/test_agents — 33/33 passing (7 new tests covering extract_cost behavior across claude, cursor, gemini, antigravity)
  • ruff check clean on all files touched in this PR
  • Full suite run: 647 passed, 6 pre-existing failures unrelated to this change (Windows cp1252 encoding in test_runner.py, file-permission checks in test_cloud.py, unrelated dashboard tests)

karthickmk2001 and others added 2 commits September 21, 2026 13:34
Contributors had no documented path to extend secfoo with a new agent
CLI, even though the AgentAdapter base class + registry.py already
supported it cleanly. Adds a CONTRIBUTING.md section (mirroring the
existing skill-authoring one) and a README pointer to it.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
secfoo cost previously only reported spend for the built-in secfoo/
LangGraph agent, silently leaving cost_usd NULL for every run through
claude/cursor/antigravity/gemini even though the README implied cost
was tracked per run in general.

Adds an extract_cost() hook to AgentAdapter, wired into run()'s
success path alongside the existing extract_report() hook. Claude
Code reports its own total_cost_usd in --output-format json, so
ClaudeAdapter now parses and returns it -- a real CLI-reported figure,
not an estimate. Cursor, Antigravity, and Gemini CLI don't report a
cost figure in their output, so those adapters intentionally leave
cost_usd unset (documented inline) rather than guess from token
counts against a pricing table we'd have to keep current. README and
CONTRIBUTING.md updated to describe the actual coverage.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@karthickmk2001 karthickmk2001 changed the title Agent adapter extensibility docs + AI spend tracking for Claude Code feat(agents): document adapter extensibility and track Claude Code AI spend Sep 22, 2026
@karthickmk2001 karthickmk2001 changed the title feat(agents): document adapter extensibility and track Claude Code AI spend feat(agents): document adapter extensibility, add Claude adapter cost tracking Sep 22, 2026
@karthickmk2001 karthickmk2001 changed the title feat(agents): document adapter extensibility, add Claude adapter cost tracking Feat(agents): Document adapter extensibility, add Claude adapter cost tracking Sep 22, 2026
@karthickmk2001

Copy link
Copy Markdown
Collaborator Author

Closing this. SecFoo development has moved to the private repository, and cost tracking has since been implemented there (per-run AI cost tracking, plus CI controls: --fail-on, --max-cost, --json and portal cost ingest). No further work will happen on this branch.

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.

2 participants