Skip to content

feat: implement tool calls history UI and API (fixes #27)#28

Merged
vivganes merged 2 commits into
ampyard:mainfrom
kirankashyap:fix/tool-calls-history
Jul 15, 2026
Merged

feat: implement tool calls history UI and API (fixes #27)#28
vivganes merged 2 commits into
ampyard:mainfrom
kirankashyap:fix/tool-calls-history

Conversation

@kirankashyap

Copy link
Copy Markdown
Contributor

Summary

This PR implements Issue #27, adding a detailed "Call History" view to the Tool Stats page. It allows users to quickly inspect past tool invocations, their exact inputs (arguments), and the model's responses without having to dig through full session logs.

What changed:

  • Backend (analysis.py): Updated the /analysis/tool/{tool_id} endpoint to parse tool_call, tool_result, and tool_error events across all sessions. It now returns a calls_history array containing the parsed arguments, output payloads, status flags, and latency, strictly sorted in reverse chronological order (most recent first).
  • Frontend (ToolStats.tsx): Built out a new "Call History" UI section on the Tool Stats page. It lists the invocations elegantly, applying specific badging depending on success/error/hallucination status, and includes expandable <details> sections to inspect the raw JSON inputs and outputs.
  • Testing (test_analysis.py): Added a comprehensive suite of backend tests that verify successful aggregations, error state handling, reverse chronological sorting, and empty state behavior.
  • Seeding (seed_tool_history.py): Added a local utility script to inject realistic dummy tool calls into harness.db so reviewers can easily verify the UI locally without requiring an LLM API key.

Testing

  • Backend tests (cd backend && uv run pytest -v --tb=short)
  • Frontend tests (cd frontend && npm test)

Manual Verification

  1. Run cd backend && uv run python seed_tool_history.py to seed your local harness.db with dummy tool history data.
  2. Start the backend (cd backend && uv run fastapi dev app/main.py) and frontend (cd frontend && npm run dev).
  3. Navigate to http://localhost:5173/tools.
  4. Click the Stats icon next to the summon_cat tool.
  5. Scroll down to the new Call History section and verify the layout, the reverse chronological ordering, and the expandable Input/Output views for both successful and failed tool calls.

@vivganes
vivganes merged commit 46cefa3 into ampyard:main Jul 15, 2026
2 checks passed
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