Skip to content

fix: retain fitting OpenAI read baselines - #14

Merged
jalehman merged 2 commits into
masterfrom
lore-b74.15/openai-token-budget
Aug 8, 2026
Merged

fix: retain fitting OpenAI read baselines#14
jalehman merged 2 commits into
masterfrom
lore-b74.15/openai-token-budget

Conversation

@jalehman

@jalehman jalehman commented Aug 8, 2026

Copy link
Copy Markdown

What

Keep the newest successful singleton read exact when the complete OpenAI provider request is proven to fit its token window.

Why

The Unicode-safe byte fallback projected a 61.9 KB canonical page even though the full Terra request used only about 64k message tokens. That prevented staged ingestion proposals from preserving required update baselines.

Changes

  • Preserve the byte-safe fallback first
  • Restore only the newest singleton read
  • Count the provider-transformed OpenAI request
  • Reject dense Unicode and mutation outputs

Testing

  • bun test test/ai/gateway-tool-loop-openai-budget.test.ts test/ai/tool-loop-context-exact-results.test.ts test/ai/gateway-tool-loop.test.ts
  • bun run typecheck
  • Autoreview clean

@jalehman

jalehman commented Aug 8, 2026

Copy link
Copy Markdown
Author

Merge gate: exact production transcript replay retained the 61,900-byte latest read at 107,045 estimated total tokens; focused tests 33/33, typecheck, repository verify, static/security checks, mechanical tier, LLM skill tier, JSONB parity, and specialized slow tests passed. Shard 7/9/10 failures exactly reproduce on the prior head and are unrelated database/extraction failures. Serial failed on an unrelated temporary Git index.lock race. Proceeding under the explicitly authorized ingestion repair/deploy.

@jalehman
jalehman merged commit 6e4fb03 into master Aug 8, 2026
15 of 21 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.

1 participant