openclaw/extensions/agentsapi
Sarah Fortune 4c40118d65
feat(agentsapi): preserve native output and tool history (#156182)
* feat(agentsapi): project native output and reconcile saved history

* fix(agentsapi): retain observed usage after accounting read failures

ClawSweeper: "Retain observed usage when the final REST read fails"
https://github.com/openclaw/openclaw/pull/156182#issuecomment-5789452458

Merge final REST usage with observed usage by admitted turn ID. Canonical
records replace matching contributions, while omitted turns keep observed
usage and repeated accounting does not double count them.

* test(agentsapi): cover projection usage and authoritative session receipts

* refactor(agentsapi): keep projection implementation helpers module-local

* test(agentsapi): use the projection factory and preserve fixture types

---------

Co-authored-by: Sarah Fortune <sarah.fortune@gmail.com>
2026-09-23 21:18:27 -07:00
..
assets fix(agentsapi): package the bundled plugin icon, activity mark, and agent-runtimes category (#156549) 2026-09-23 14:08:59 +00:00
agentsapi-bindings.ts
agentsapi-client.test.ts feat(agentsapi): enable native live web search (#156306) 2026-09-23 07:54:02 +00:00
agentsapi-client.ts feat(agentsapi): preserve native output and tool history (#156182) 2026-09-23 21:18:27 -07:00
agentsapi-harness.ts feat(agentsapi): preserve native output and tool history (#156182) 2026-09-23 21:18:27 -07:00
agentsapi-messages.test.ts feat(agentsapi): preserve native output and tool history (#156182) 2026-09-23 21:18:27 -07:00
agentsapi-messages.ts feat(agentsapi): preserve native output and tool history (#156182) 2026-09-23 21:18:27 -07:00
agentsapi-native-items.ts feat(agentsapi): preserve native output and tool history (#156182) 2026-09-23 21:18:27 -07:00
agentsapi-native-tool-projection.ts feat(agentsapi): preserve native output and tool history (#156182) 2026-09-23 21:18:27 -07:00
agentsapi-session.test.ts feat(agentsapi): preserve native output and tool history (#156182) 2026-09-23 21:18:27 -07:00
agentsapi-session.ts feat(agentsapi): preserve native output and tool history (#156182) 2026-09-23 21:18:27 -07:00
agentsapi-transcript.ts feat(agentsapi): preserve native output and tool history (#156182) 2026-09-23 21:18:27 -07:00
index.ts
openclaw.plugin.json fix(agentsapi): package the bundled plugin icon, activity mark, and agent-runtimes category (#156549) 2026-09-23 14:08:59 +00:00
package.json refactor(agentsapi): use the official OpenAI SDK (#156116) 2026-09-22 22:40:36 -07:00
README.md
tsconfig.json

Agents API harness

The agentsapi harness uses API-key authentication and an OpenAI-hosted Linux environment. Select it through agents.defaults.agentRuntime.id or an agent's agentRuntime.id. See the harness configuration reference.

Token accounting reads canonical native turn records after settlement, since completion stream events can omit usage. Each OpenClaw attempt counts its new coordinator turns once, including work superseded by steering. Earlier turns in the same native session are excluded. Cached input is counted separately from uncached input; reasoning tokens remain included in output tokens.

Successful assistant messages retain those totals in the OpenClaw transcript. Run results and completion hooks also retain usage reported for interrupted or failed work after native cleanup settles. Historical session usage is derived from transcript messages, so interrupted work without an assistant message is not included in that historical report. A bounded five-second settlement window waits for late turn records and usage. Counts are not refreshed after that snapshot. Accounting read failures retain the last available snapshot and log a warning; they do not discard a completed reply or replace cancellation. Missing native usage remains unavailable; native counts can change as upstream accounting arrives. See the official usage guide.

Native turn billing can sum multiple model calls. It does not establish the current context-window usage. Cost estimates use the configured model prices; they are not provider billing receipts.