feat(status): add API call count to session status and usage footer#48851
feat(status): add API call count to session status and usage footer#48851Qixingchen wants to merge 3 commits intoopenclaw:mainfrom
Conversation
- track API call count per run in embedded runner - persist per-run call count on session entries - show current-turn call count in /status output - show current-turn call count in response usage footer - keep calls semantics aligned with current-turn token usage - add/update unit tests for API call count display
Greptile SummaryThis PR adds API call count tracking (
Confidence Score: 3/5
|
There was a problem hiding this comment.
Pull request overview
Adds per-turn API call count tracking to the embedded agent runner and surfaces it in user-facing status/usage output, complementing existing per-turn token usage reporting.
Changes:
- Introduces
callCounton embedded runner metadata and persists it ontoSessionEntry. - Displays
📞 Calls: Nin/statusand in the response usage footer. - Adds/updates unit tests covering call count formatting in both outputs.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/config/sessions/types.ts | Adds SessionEntry.callCount to persist last-run (current turn) API call count. |
| src/auto-reply/status.ts | Includes 📞 Calls: N in the /status usage line when available. |
| src/auto-reply/status.test.ts | Tests that /status includes call count from the latest run. |
| src/auto-reply/reply/session-usage.ts | Persists callCount onto session store entries. |
| src/auto-reply/reply/agent-runner.ts | Plumbs runner callCount into session persistence and usage-footer formatting. |
| src/auto-reply/reply/agent-runner-utils.ts | Extends usage footer formatting to include call count. |
| src/auto-reply/reply/agent-runner-utils.test.ts | Tests usage footer formatting with call count. |
| src/agents/pi-embedded-runner/types.ts | Adds callCount to embedded runner agent meta type. |
| src/agents/pi-embedded-runner/run.ts | Tracks and reports per-run API call count via the usage accumulator. |
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0436875ad3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Bot review feedback: callCount was missing in followup-runner.ts persistRunSessionUsage call, causing stale count after followup turns. This aligns with how usage/lastCallUsage are already handled there.
- Add callCount tracking in subscribeEmbeddedPiSession (incremented on each recordAssistantUsage call, i.e., each LLM API response with usage data) - Add attemptCallCount to EmbeddedRunAttemptResult - Pass callCount from attempt to run.ts and accumulate properly - Add tests for callCount accumulation scenarios This fixes the issue where callCount only counted attempts, not individual API calls within tool-call loops.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 50b4858035
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Summary
callCounttracking in the embedded runner, persisted to session entry, displayed in both/statusand response usage footerChange Type
Scope
Linked Issue/PR
User-visible / Behavior Changes
/statusoutput now includes📞 Calls: Nin the usage line (current turn only)📞 Calls: NwhenresponseUsageis enabled (current turn only)Security Impact
Repro + Verification
Environment
Steps
/statuscommand in any session with prior activity📞 Calls: NresponseUsage: fullin configExpected
🧮 Tokens: 154k in / 656 out · 💵 Cost: $0.40 · 📞 Calls: 3
Actual
Works as expected.
Evidence
src/auto-reply/status.test.ts- "shows API call count from the latest run"src/auto-reply/reply/agent-runner-utils.test.ts- "formats response usage line with API call count"Human Verification
Review Conversations
Compatibility / Migration
Failure Recovery
Risks and Mitigations
None. This is a display-only feature with no side effects.