Commit Graph

20 Commits

Author SHA1 Message Date
can1357 992963f949 feat(coding-agent): allowed switching to models smaller than session context with compaction
- Make over-context models selectable in the model picker by graying them instead of disabling them.
- Trigger automatic session compaction with the current model prior to switching when an over-context model is chosen.
2026-08-01 20:59:24 +02:00
can1357 461971a49b test(session): cover model change event emission
(cherry picked from commit fd4b388c6947fb28539653ae56d61bf988f1b5ab)
2026-07-29 23:08:27 +02:00
can1357 42d705f4a7 test: use transcript-mode session context in model persistence assertions
buildSessionContext now drops failed tails by default (#6357); these
assertions inspect the interrupted tail and need transcript mode.
2026-07-23 11:49:25 +02:00
Christian Stewart bdad9ca8c0 fix(session): recover interrupted switched sessions
Close pending tool turns recorded during normal shutdown and apply interrupted-tail recovery when switching or reloading sessions.

Signed-off-by: Christian Stewart <christian@aperture.us>
2026-07-11 16:18:39 -07:00
Christian Stewart de236903d4 fix(session): close all interrupted transcript tails
Detect pending tool calls from assistant content and use the selected model metadata to terminate first-turn user tails after abnormal process exits.

Signed-off-by: Christian Stewart <christian@aperture.us>
2026-07-11 16:18:39 -07:00
Christian Stewart e3e5bf8775 fix(session): recovered interrupted session turns
Appended one terminal aborted assistant record when a persisted abnormal-exit diagnostic follows a non-terminal transcript tail, preserving partial history while making resumed context valid.

Signed-off-by: Christian Stewart <christian@aperture.us>
2026-07-11 16:18:39 -07:00
roboomp a06d0c54b3 fix(session): switched models during goal recovery
Removed the live-context guard that let default model selection persist a new role without changing the active session model. The next prompt's compaction path now owns oversized-context recovery after a switch.

Fixes #4219
2026-07-02 06:48:30 +00:00
roboomp a4ae4c130c fix(coding-agent): preserved explicit :auto suffix in modelRoles
The model selector's persistence path dropped the `:auto` selector when parsing role values, producing a warning ('Invalid thinking level "auto"') and rendering the badge as `inherit` instead of `auto`. Reload of the default role also lost the auto state whenever the role value carried an explicit `:auto` suffix instead of relying on `defaultThinkingLevel`.

Widen the resolver chain (`parseThinkingSuffix`, `splitThinkingSuffix`, `parseModelString`, `parseModelPattern*`, `ResolvedModelRoleValue`, `ResolvedRoleModel`, `ResolveCliModelResult`) to carry the `AUTO_THINKING` sentinel end to end, and coerce it back to `undefined` at concrete-only boundaries (glob scope patterns, retry fallback, advisor, commit pipeline, guided-goal, bench).

Regression tests cover:

- `resolveModelRoleValue("provider/model:auto")` returns explicit auto without a warning.

- `ModelSelector` renders `DEFAULT (auto)` and `SMOL (auto)` when the role value has `:auto`.

- `cycleRoleModels` activates auto thinking on entering a `:auto` role.

- Startup resume activates auto thinking when `modelRoles.default` carries `:auto`.

Fixes #4128
2026-07-01 08:18:42 +00:00
roboomp f82086f805 refactor(coding-agent): moved Alt+M context gate into setModel
Replaced the controller-side switchActiveModel flag with a currentContextTokens hint on AgentSession.setModel, so the over-context decision is computed against the refreshed candidate metadata. setModel returns whether the live switch happened, and the Alt+M default-role path uses that to gate the live side effects.
2026-06-28 07:13:03 +00:00
roboomp 3765d80cbc fix(coding-agent): fixed alt-m default over context
Decoupled default-role persistence from live model switching when the selected model is below the current session context window.

Updated the model selector regression coverage so the Alt+M Default action remains selectable and advances to thinking selection.

Fixes #3708
2026-06-28 07:04:31 +00:00
can1357 24c8bb24c6 feat(session): added modular session APIs and rebuilt listing/persistence behavior
- Added session-domain modules and exports for session-entries, context, listing, loader, and migrations.
- Changed persistence to async append writes plus writeTextAtomic, removing sync line APIs.
- Added compaction-aware session context rebuild with dangling tool-call cleanup.
- Added resumable session resolution with status inference, id/stem/suffix matching, and backup recovery.
2026-06-14 02:02:53 +02:00
can1357 1b9d9d0851 refactor(catalog)!: split model catalog from pi-ai
Move bundled models, model cache/manager, thinking metadata, effort helpers,
provider descriptors/discovery, wire constants, and model identity utilities
into the new @oh-my-pi/pi-catalog package.

Update pi-ai to keep provider runtime/auth concerns, move catalog provider
metadata into CATALOG_PROVIDERS, and migrate coding-agent, agent, stats, docs,
and tests to import catalog values from pi-catalog.

Split coding-agent model registry helpers into discovery, roles, and models
config modules while preserving registry orchestration.

BREAKING CHANGE: @oh-my-pi/pi-ai no longer exports catalog subpaths such as
/models, /model-cache, /model-manager, /model-thinking, /effort,
/provider-models*, discovery helpers, and provider wire constants; use the
matching @oh-my-pi/pi-catalog subpaths instead.
2026-06-10 04:06:57 +02:00
can1357 20d19e8002 test: replaced blind sleeps with shared fixtures and condition polling
- Shared immutable model registries and auth storage via beforeAll/afterAll.
- Swapped fixed-delay settle sleeps for predicate polling and signals.
- Stubbed network/timers to drop wall-clock waits in registry and history tests.
- Added resetDisplay invalidation tests and startup-timing breakdown lines.
2026-06-06 22:09:04 +02:00
can1357 7124dbae93 fix(coding-agent): fixed session resume to reconcile modes and preserve model state
- Registered and triggered a session-switch reconciler during init and after switch.
- Rebuilt resume flow to restore plan/goal mode state and clear stale mode flags.
- Marked fallback and context-promotion model switches ephemeral and skipped them on restore.
- Added regression tests for temporary model ordering, fallback precedence, and mode cleanup.
2026-06-04 17:22:19 +02:00
roboomp cf9eb5b0f9 fix(coding-agent): skipped temporary resume models
Treat temporary model_change roles as non-restorable when resuming sessions so context-promotion and retry-fallback models do not override the saved default.\n\nFixes #1649
2026-06-02 09:15:45 +02:00
roboomp 43405962b7 style: bun run fix 2026-06-02 09:15:45 +02:00
roboomp 00adc9c5d6 fix(coding-agent): fell back to saved default on resume
Try the last active role model first, then the saved default model when the role model cannot be restored during session switching or startup resume.\n\nFixes #1649
2026-06-02 09:15:45 +02:00
roboomp 8e1f53fee6 style: bun run fix 2026-06-02 09:15:44 +02:00
roboomp bb0991e6f3 fix(coding-agent): restored last active role model
Use the last model_change role when resuming an existing session instead of always restoring models.default. Covered both /resume switchSession and startup continue paths.\n\nFixes #1649
2026-06-02 09:15:44 +02:00
can1357 346ae48b0c fix(session): prevented runtime model switches from persisting default role
- Restricted `setModel` to persist settings only when `persist: true` is passed; all runtime switches (Ctrl+P, `--model`, `/model`, model picker temp selections) no longer overwrite `modelRoles.default`.
- Changed `cycleRoleModels` to accept a direction ("forward"/"backward") instead of a `temporary` flag; both directions now use `applyRoleModel` without persisting.
- Added `persist: true` exclusively to the model picker's "Set as default" action in `SelectorController`.
- Added test suite covering persistence behavior for `setModel`, `cycleRoleModels`, and `cycleModel`.
2026-05-31 06:21:29 +02:00