feat: dynamic Copilot model discovery and context tiers - #3
Conversation
Pi resolves enabledModels during startup before session_start. Registering the discovery provider on session_start left scoped models like gemini-3.6-flash and grok-4.5 missing until /copilot-refresh. Run best-effort /models discovery during extension load, register the provider override immediately, and resolve the built-in provider via builtinProviders() (jiti-safe import). Co-authored-by: Cursor <cursoragent@cursor.com>
|
@milespossing, fixed another small problem, enjoy ;) |
|
I also created a PR to get the sort to work in pi.dev: earendil-works/pi#7692 |
|
Hey sorry for the delay. Shipping a few things. This all looks good to me, but let me test it and set up some automation so you don't need to wait so long for me to do a bunch of manual stuff |
| return builtin; | ||
| } | ||
|
|
||
| function getAuthPath(): string { |
There was a problem hiding this comment.
Hey in the past I had some strange issues with auth and stored creds. I'm not sure what you've done here is wrong, but the behavior I saw before was that the extension would start and work for maybe an hour or so, but eventually we would get token expired exceptions.
I'm not reading super closely yet, but I wanted to be sure that pi is still owning the token acquisition and we aren't exposing ourselves to auth token rot
There was a problem hiding this comment.
i will admit, i vibed through the issue, i dont know much about pi, but the outcome was good, doesnt mean what i did is 'correct'
|
Alright just did some reading and validation. I don't see any issues in my validations, but I'm just slightly concerned about the shift back towards wrapping and owning auth. As I mentioned in my other comment, there were issues with token refresh when I'd first started to make this work in this way. If you've been using this new version for a while, then I imagine it's fine and you found the right balance with the tokens (or pi has improved this aspect of its api), but I want to be sure |
|
i have been fighting it a little, because when i restart pi, sometimes it will remove models that i have already added by using /scoped-models, i have had the seam traced, but pi will dump the models if the auth is expired on the next rerun of pi from the shell |
|
i feel like pi should reauth before it goes and says xyz model is not found |
|
next battle: PS C:\temp\test pi> pi pi v0.84.0 Pi can explain its own features and look up its docs. Ask it how to use or extend Pi. |

Summary
Billing behavior
Copilot reports token prices in AI credits per million tokens, where one AI credit is $0.01. The extension converts those values to the dollar-per-million-token rates expected by Pi. The smaller context alias uses the default tier, while the larger alias retains Pi's automatic long-context cost tier.
Validation
The local Pi installation was switched from the stale npm package to this checkout so the installed workflow is exercised while the PR is reviewed.
Base-branch note
The upstream main branch already contains the responses-only routing change in src/families.ts. The fork-local comparison therefore shows 7 changed files, while this upstream-targeted PR correctly shows 6. The final head tree still contains the same src/families.ts content; it is simply already present in the upstream base. The billing fix is included in commit 661ae63 and is part of this PR.