Read issue and related comments.
UnderstandReviewed all related code files.
UnderstandTraced code path for root cause.
UnderstandProposed fix based on analysis.
PlanAnalyze GitHub issue(s): https://github.com/badlogic/pi-mono/issues/844
For each issue:
Do NOT implement unless explicitly asked. Analyze and propose only.
Planning GitHub issue retrieval
I'm preparing to use a bash command to read the issue details via GitHub CLI.
>gh issue view 844 --json title,body,comments,labels,statePlanning code exploration
I'm preparing to read related files fully and search for /scoped-models and /model to locate relevant code for better understanding.
>rg -n "scoped-models|scoped models|/scoped" packagesPlanning full reads of key files
I'm targeting full reads without offsets for interactive-mode and related components handling model selection and session, planning parallel reads for smaller files but ensuring complete reads of large files like interactive-mode.ts.
Confirming use of parallel reads
Planning segmented file reads
The initial full read of the large file hit truncation, so I'll read the remainder in segments using offsets despite the "no offset" rule for full reads, as this is necessary to access the missing parts like the handleModelCommand and showModelsSelector functions. I'll locate these using line-aware search within the file.
Using targeted searches to locate key functions
I'm planning to run line-numbered searches for handleModelCommand and related selectors to identify their positions, then read those file sections with offsets for focused analysis without full file editing.
>rg -n "handleModelCommand|showModelsSelector|showModelSelector|scoped models|scoped-models" /Users/badlogic/workspaces/pi-mono/packages/coding-agent/src/modes/interactive/interactive-mode.tsPlanning to use read with offset
Requesting continuation from offset
Planning targeted scan for scoped model logic
I'll focus on searching relevant keywords in the agent-session file to find scoped models and enabled models handling instead of loading the entire large file.
>rg -n "scoped model|scopedModels|enabled models|enabledModels" /Users/badlogic/workspaces/pi-mono/packages/coding-agent/src/core/agent-session.tsLocating model registry module
I'm focusing on finding the model registry code, likely under core/model-registry, to understand its structure and usage.
>rg -n "class ModelRegistry|getAvailable" /Users/badlogic/workspaces/pi-mono/packages/coding-agent/src/core/model-registry.tsPrioritizing full read of model resolver
I'll read the entire core/model-resolver.ts file to understand the resolveModelScope function and its role in handling enabled models and patterns, as it's relevant for interactive mode.
Tracing session scoped models initialization
I'm investigating where session scoped models get set from settings.enabledModels at startup, focusing on main or core modules and searching for usage of getEnabledModels or enabledModels to understand why session.scopedModels remains set without CLI flags.
>rg -n "getEnabledModels|enabledModels" /Users/badlogic/workspaces/pi-mono/packages/coding-agent/srcReading main file for analysis
Identifying model scope bug
Found that /model command currently shows only scoped models from persisted settings instead of all models; /scoped-models should control cycling scope only. The fix is to ignore settings-scoped models for /model or add a toggle, restricting scopedModels use in the selector to CLI scope only.
Distinguishing scope sources for models
Tracing shows session.scopedModels merges CLI and settings scopes, causing /model and autocomplete to improperly filter by persisted settings scope. To fix, propose separating cycling scope (from settings or /scoped-models) from model selection scope (CLI only), adding metadata to track scope origin and ensuring /model always shows all models unless explicitly scoped by CLI.
Tracing model scoping root cause
The root cause is that /model uses session.scopedModels, which is set from settings enabledModels and scopes available models, causing /model to hide others when scoped models exist. The fix is to decouple /model's listing from scopedModels or add a toggle to show all models. I'll outline paths and propose a concise change to separate scoping for /model from session.scopedModels.
Analyzing model scope handling
A non-empty scopedModels from saved settings causes /model and autocomplete to show only scoped models, hiding others permanently. The fix is to decouple cycling scope from /model listing by updating interactive-mode to have /model always use the full set from modelRegistry.getAvailable and show a hint about cycling scope. This keeps cycling scoped but lets users see all models in /model as expected. Key files to update are interactive-mode’s model candidate methods and model selector component to remove scopedModels filtering and adjust UI hints accordingly.
Issue 844 (bug)
Summary of code path and root cause
Proposed fix
Most concise implementation approach
Affected files
No linked issues or PRs were referenced in the issue.