24 Commits

Author SHA1 Message Date
roboomp 8afd71d921 fix(coding-agent): classify user-invoked /skill turns under auto thinking
A user-invoked /skill:<name> reaches the session as a user-attributed skill custom message (role custom, attribution user) whose expanded SKILL.md body is the task prompt. The auto-thinking gate in #promptWithMessage only accepted role === "user", so these turns skipped classifyDifficulty/applyAutoThinkingLevel and the effort stayed stuck on pending auto.

Broaden the gate to also accept user-invoked skill prompts via the now-exported isUserInvokedSkillPrompt helper; agent-originated and autoload skill injections stay excluded.

Fixes #8554
2026-08-14 13:27:01 +00:00
can1357 b279db1790 test: refactored test suites to eliminate time-based sleeps and polling loops
- Replaced time-based sleeps and polling loops with event-driven promise resolvers and fake timers across agent and tool tests.
- Migrated test suites to share in-memory auth storage and fixtures using lifecycle hooks.
- Updated catalog model definitions, metadata, and configurations.
2026-08-13 19:32:22 +02:00
roboomp 5d9cbf19e6 fix(session): preserved auto-thinking level on classifier failure
- Kept the last successfully classified effort when a later classification fails.
- Added regression coverage for the success-then-failure transition.

Fixes #6877
2026-07-28 08:06:17 +00:00
phrazzld f04741eac2 fix(thinking): persist auto selector receipt 2026-07-19 19:11:30 -05:00
roboomp 9bda84b685 fix(coding-agent): respected role thinking for temp picks
Applied explicit thinking suffixes from matching configured model roles when the temporary model picker switches the session model.

Added regression coverage for the Alt+P temporary picker resolution path.

Fixes #5290
2026-07-12 19:01:05 +00:00
can1357 d435385ab1 feat: introduced max reasoning effort tier across model and rpc systems
- Introduced `Max` as a first-class reasoning effort tier across all packages, including AI providers, coding agent configurations, and RPC protocols.
- Refactored model effort ladders to use wire-exact mappings and removed legacy effort aliasing (e.g., `max-to-xhigh` mapping).
- Updated model registry and provider configurations to support `Max` tier routing, color themes, and UI icon associations.
- Expanded test suites to provide end-to-end coverage for the new reasoning tier, including updated compatibility and fallback scenarios.
2026-07-10 13:39:42 +02:00
can1357 73ef29bd00 fix(session): corrected branch traversal order breaking ctrl+p cycling
- Removed a duplicated branch.reverse() left by the PR #3862 merge in
  SessionEntryIndex.pathTo(), which returned branches leaf-to-root and made
  getLastModelChangeRole() read the oldest model change instead of the
  newest — pinning the ctrl+p cycle to one slot and breaking session model
  restore.
- Hardened getRoleModelCycle() to trust the recorded role only while its
  resolved model still equals the active model, falling back to matching by
  model after switches through alt+m, /model, or retry fallback.
- Added mutation-verified regression tests for branch ordering and the
  stale-role fallback.
2026-07-01 23:48:26 +02: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
can1357 0ca62f1b8b Merge PR #1865: fix(session): keep auto thinking mode active across session resume (@msimon) 2026-06-21 17:09:50 +02:00
roboomp cafd957f5d fix(providers): disabled ollama thinking for off turns
Propagated explicit thinking-off state through the agent loop so provider requests receive disableReasoning instead of an undefined effort. Added Ollama and agent-session regressions for the :off path.\n\nFixes #2239
2026-06-10 07:41:58 +00: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 9d457f73d9 test: migrated test imports to package subpath exports
- Replaced relative `../src` imports with `@oh-my-pi/pi-ai` and `@oh-my-pi/pi-agent-core` subpaths.
2026-06-08 19:03:55 +02:00
Marc Simon 35a72e75db fix(session): keep auto thinking mode active across session resume
Auto thinking was silently downgraded to a frozen concrete level whenever a
session was resumed (--continue/--resume/switch). The session log persisted
only the per-turn *resolved* effort, so on restore the code could not tell
"user pinned medium" from "auto resolved to medium this turn"; it cleared
auto mode and pinned the level, and the next turn never reclassified.

Persist the configured selector alongside the resolved level:

- ThinkingLevelChangeEntry gains an optional `configured` field ("auto" or a
  concrete level); SessionContext surfaces `configuredThinkingLevel`.
- The three append sites record the configured selector; auto turns record
  "auto" while keeping the resolved effort in `thinkingLevel` for display.
- Both restore paths (AgentSession.switchSession and sdk cold resume) prefer
  the configured selector, so an auto session resumes in auto mode (shown as
  pending `auto`) and reclassifies on the next turn -- consistently across
  cold --continue and the in-app switcher. A manual concrete pin still
  restores as concrete, even when the global default is auto.
- Leaving auto persists even when the pinned effort equals the level auto just
  resolved to, so the concrete pin (and defaultThinkingLevel) is recorded
  instead of leaving a stale `configured: "auto"` that would re-enable auto.

Entries written before `configured` existed fall back to the concrete level
(legacy pin-on-resume behavior), so old sessions are unaffected.

Adds a CHANGELOG entry and tests covering resume-stays-auto, manual-pin-stays-
concrete, and pin-equal-to-auto-resolved-effort.
2026-06-04 15:55:37 +01: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
can1357 5344bcbc69 fix(coding-agent): persisted resolved auto thinking level on session resume
- Auto classification now writes the concrete effort to the session log after the first real user turn.
- Resumed sessions restore the last resolved effort instead of reverting to pending auto.
- Added `dedupeReply` opt-out flag for ephemeral turn reply deduplication.
2026-05-31 04:10:52 +02:00
can1357 7f866a48a8 feat(coding-agent): added per-turn AUTO_THINKING in coding-agent session
- Added AUTO_THINKING as a configured thinking level in settings, schema, SDK, and session plumbing.
- Implemented per-turn auto reasoning classification with online/local prompts, effort clamping, and skip guards.
- Updated model selectors, ACP options, footer/status UI, and events to render auto and auto->resolved states.
- Added AUTO_THINKING parse/clamp tests and fixed local-module cycle and hashline preview regressions.
2026-05-31 03:32:21 +02:00
can1357 8c323666be feat: added ordered systemPrompt arrays and normalized context prompts
- Converted systemPrompt APIs and state types to ordered `string[]` across agent, AI, and coding-agent surfaces.
- Added `normalizeSystemPrompts` and applied it to context normalization before building provider request payloads.
- Updated AI providers to emit separate normalized prompt blocks/messages instead of a single merged system prompt.
- Removed dedicated `projectPrompt` state and remapped that context into system-context buckets in session, dump, and token accounting.
- Aligned tests and changelogs to pass and assert `systemPrompt` as arrays with ordered prompt semantics.
2026-05-04 15:20:26 +02:00
can1357 2f151fea9a fix(tests): added resource cleanup methods and initiatorOverride support
- Added `close()` method to SessionManager and AuthStorage for proper resource cleanup and finalization of prepared statements.
- Added `initiatorOverride` option support in OpenAI and Anthropic providers for message attribution control.
- Fixed resource leaks in RpcClient timeout handling by centralizing timeout creation with unref() and adding explicit clearTimeout() calls.
- Fixed AgentSession disposal to call SessionManager's `close()` method for guaranteed resource cleanup instead of fallback flush.
- Updated all test suites to properly dispose AuthStorage instances in cleanup hooks to prevent resource leaks between tests.
2026-03-14 11:25:40 +01:00
ravshansbox 99b6be6518 Include off in thinking level cycling (#404) 2026-03-14 10:41:06 +01:00
can1357 8e3e0ebf9e feat: introduced Effort enum and ThinkingConfig for model-aware reasoning
- Introduced Effort enum and ThinkingConfig metadata for per-model reasoning capabilities with min/max effort levels.
- Migrated thinking level API from string-based ThinkingLevel to structured Effort enum across agent and AI packages.
- Added model-thinking module with effort mapping, policy application, and semantic versioning utilities for provider-specific thinking modes.
- Removed supportsXhigh() function and replaced effort clamping with model-aware validation using ThinkingConfig metadata.
- Expanded models.json with thinking configuration objects for 50+ models including Claude, Gemini, and OpenAI variants.
- Added Python analysis scripts for edit tool usage patterns and tool invocation stream processing.
2026-03-06 12:35:01 +01:00
can1357 10242a445a refactor(ai): renamed reasoningEffort to reasoning across providers
- Updated option interfaces, param builders, and stream functions to use unified `reasoning` field.
- Added `resolveOpenAiReasoningEffort()` to centralize xhigh clamping logic.
- Replaced type casts with `castApi()` helper and fixed test option names.
- Updated coding-agent and benchmark references for consistency.
2026-03-05 00:25:12 +01:00
can1357 2e001bbf8d fix(coding-agent): fixed model selector to handle multiple roles on same model
- Added formatRoleThinkingModeLabel helper to display 'inherit' for default thinking mode, preventing badge ambiguity when multiple roles share the same model. Enhanced role menu labels to include role tags for clarity. Fixed model resolver to avoid substring matching that could incorrectly resolve exact model IDs to similar variants.
2026-03-04 23:21:10 +01:00
can1357 a8c1ea4b5e fix(coding-agent): preserve role alias thinking metadata 2026-03-03 06:14:00 +01:00
maximhar 8b7893d042 feat(coding-agent): add per-role thinking specs and inline badge effort display 2026-03-03 06:12:51 +01:00