bare-agent 0.38.0 → 0.38.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  # bareagent — Integration Guide
2
2
 
3
3
  > For AI assistants and developers wiring bareagent into a project.
4
- > v0.38.0 | Node.js >= 18 | zero required deps (`bareguard >=0.9.0 <0.14.0` optional peer for governance) | Apache 2.0
4
+ > v0.38.1 | Node.js >= 18 | zero required deps (`bareguard >=0.9.0 <0.14.0` optional peer for governance) | Apache 2.0
5
5
  >
6
6
  > Full human guide with composition examples, design philosophy, and recipes: [Usage Guide](docs/02-features/usage-guide.md)
7
7
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-agent",
3
- "version": "0.38.0",
3
+ "version": "0.38.1",
4
4
  "files": [
5
5
  "index.js",
6
6
  "index.d.ts",
package/src/loop.js CHANGED
@@ -850,7 +850,13 @@ class Loop {
850
850
  // Prefer the model the response reports (robust when provider.model is absent or varies per
851
851
  // response — e.g. FallbackProvider, or a CircuitBreaker-wrapped provider that drops .model).
852
852
  const model = result.model || this.provider.model || null;
853
- const { cost: roundCost, source: rateSource } = resolveRoundCost(result, model, lastUsage, this.rates);
853
+ // BA-23: price THIS round's usage, never the stale `lastUsage` carry-over. `lastUsage` is a truthy
854
+ // zero-object seed (line 530) kept across null/absent-usage rounds (line 832) for the BA-5 returns +
855
+ // ctx.usage publish — but handing it to the resolver made its `if (!usage) return {cost:null}` branch
856
+ // (resolveRoundCost line ~229) DEAD: a genuinely no-usage round was laundered into costUsd:0/priced
857
+ // (against the "honest null if unpriced, never 0" contract), and a MID-RUN no-usage round was priced
858
+ // on the PREVIOUS round's tokens — a stale repeat charge. addUsage below already uses result.usage.
859
+ const { cost: roundCost, source: rateSource } = resolveRoundCost(result, model, result.usage ?? null, this.rates);
854
860
  if (isGuesstimateSource(rateSource)) this._warnGuesstimateOnce(model, rateSource);
855
861
  if (roundCost !== null) totalCost += roundCost;
856
862