fix(pi-embed): start the extensions, and refuse a metered run that is not on the gateway model - #1732
Merged
Merged
Conversation
… not on the gateway model pi emits `session_start` from `bindExtensions`, which its CLI modes call once their UI exists — `createAgentSession` never does. An embedder that skips it loads the extensions but never starts them, and the metered lane selects its model from exactly that event: so a run stayed on whatever provider key the process happened to hold, outside the gateway and unmetered, while looking healthy. `startRun` now fires it, then asserts the session really is on `<gateway>/<selected model>` and fails otherwise — under-reported usage is the one failure this lane exists to prevent.
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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.
Summary
An embedded run loaded its extensions and never started them, so the metered lane silently didn't take effect.
pi emits
session_startfromsession.bindExtensions(...)— a call its own CLI modes make once their UI exists, andcreateAgentSessionnever makes. The metered lane selects its model from exactly that event:So
startRunreturned a session on whatever provider key the process happened to hold — outside the gateway, unmetered, and indistinguishable from a healthy run. Verified against the installed pi: the same session reportsmodel: nullwithout the bind andconstructive-gateway/deepseek-v4-prowith it.startRunnow fires it, then insists on the result:The assertion only applies when the metered lane selected a model (
selectModel: falseand log-only embeddings are unaffected). Under-reported usage is the failure this lane exists to prevent, so a session that ended up elsewhere fails the run rather than billing nothing.Link to Devin session: https://app.devin.ai/sessions/450ce6d6659c47759c184ae6ec19a2a8
Requested by: @pyramation