feat: run engram on openai gpt-5 models and the flex tier - #299
Merged
Conversation
Owner
Author
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #299 +/- ##
==========================================
+ Coverage 90.89% 91.03% +0.13%
==========================================
Files 218 221 +3
Lines 22722 23099 +377
==========================================
+ Hits 20654 21029 +375
- Misses 2068 2070 +2 ☔ View full report in Codecov by Harness. |
Bundle ReportBundle size has no change ✅ Affected Assets, Files, and Routes:view changes for bundle: engram-frontend-client-array-pushAssets Changed:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes Engram usable on OpenAI gpt-5.x models and on OpenAI's cheaper flex service tier, so the curation pipeline can run without DeepSeek.
Why
The stand's pipeline has been dead since 2026-07-23 (DeepSeek 402). Moving to OpenAI is cheaper than topping up: measured on real traffic volumes,
gpt-5-nano+gpt-5-minicost ~$16/10d against DeepSeek's $170, and flex halves that again.The current gateway could not talk to gpt-5.x at all. Verified by live calls against
api.openai.comon 2026-07-27:What changed
Request shaping.
ModelPolicy.metadata['request_shape']declares how a model family wants its request spelled: which completion-token parameter, whether temperature is sent, and per-response-kindreasoning_effort. Derived automatically from the model name — presets and hand-created policies both get it, and switching a policy's model re-derives it (and dropsservice_tierif the new family has no flex).Flex tier.
service_tieris now actually sent, with the socket sized to the tier. Escalation is by attempt count, not error kind: our classifier maps flex-capacity 429 and ordinary rate-limit 429 to the same code, so they are indistinguishable — late attempts fall back to the project default so work lands instead of being lost.Flex is opt-in on both layers. A policy asks for flex; the deployment must also declare
ENGRAM_FLEX_TIMEOUT_SIZING=1before any ladder grows. Without it, applying the flex preset is refused with a message telling you what to set. This keeps zero drift for everyone else — verified value-by-value against master:Presets.
openai_allnow namesgpt-5-nano/gpt-5-miniinstead ofgpt-5.4/gpt-5.4-mini— the old pair measured 4.7× more expensive than the DeepSeek setup it replaces. A newopenai_all_flexpreset adds the flex tier. Every OpenAI preset now ships pricing, without whichcost_usdrecords 0.0000 and spend becomes unauditable.Verification
Full backend suite: 3508 passed.
End-to-end against the real API, through the real gateway and a preset-created policy:
Both real calls returned 200. No
max_tokens, notemperature. Cost is exact and halves on flex.The strict
curation_decision_v1schema was also probed against both models with the real 4432-char prompt prefix — both return valid verdicts.Known gaps
attemptis threaded from 4 of 7ProviderCallInputsites; the realtime candidate path and on-demand digest have noWorkflowWorkin scope, so they never escalate off flex.effort=low,gpt-5-nanospends more output thangpt-5-mini(1311 vs 622 tokens) — smaller model, more reasoning. Presets pinminimal.🤖 Generated with Claude Code