* fix(coding-agent): keep model and thinking level changes session scoped
* fix(coding-agent): persist requested default thinking level
* feat: --default arg to persist
* fix
* fix(coding-agent): keep model and thinking level changes session scoped
* fix: make default thinking level per model show list of models
* cleanup export
Relativize absolute find results with path.relative() instead of slicing
at searchPath.length + 1. path.resolve() keeps the trailing separator for
root paths (POSIX / and Windows bare drive roots like I:\), so the slice
dropped the first character of the first path segment. Preserve directory
markers using platform-aware separators so Windows paths do not gain "//"
and valid POSIX backslashes remain unchanged.
This also avoids treating sibling paths with a shared prefix as children.
Relative results returned by custom glob operations now pass through
unchanged instead of being resolved against process.cwd(), which produced
invalid paths whenever cwd differed from the search path.
Fixes#6104
* fix(coding-agent): resume after context-limited length stops
Treat length stops as context overflow when prompt usage is within 1% of
Pi's configured context window. Include cache-write tokens in that usage
and allow non-zero output because OpenAI may emit reasoning tokens before
returning an incomplete response.
After compaction, remove any retryable error or truncated-length assistant
message restored from persisted session history so the interrupted agent
turn can continue.
This is specifically for handling this case for openai models:
https://developers.openai.com/api/docs/guides/reasoning
> If the generated tokens reach the context window limit or the max_output_tokens value you’ve set, you’ll receive a response with a status of incomplete and incomplete_details with reason set to max_output_tokens. This might occur before any visible output tokens are produced, meaning you could incur costs for input and reasoning tokens without receiving a visible response.
This detection currently assumes the reported prompt usage is within 1% of
the context window configured in Pi. Its reliability therefore depends on
Pi's model contextWindow metadata matching the provider's effective limit.
Maybe we should consider treating OpenAI incomplete responses as requiring compaction
regardless of the local context-window estimate?
fixes#7020
* fix(coding-agent): recover truncated responses after compaction
Classify length stops by comparing provider-reported output usage with the model's intended output limit. Compact and retry once when generation ends below that limit, avoiding unreliable context-window estimates while preserving genuine max-output stops.
Normalize OpenAI Responses incomplete reasons so only max_output_tokens is treated as a length stop. Preserve qualified provider reasons for diagnostics, surface other reasons as errors, and use neutral truncation wording in the TUI.
* fix(coding-agent): preserve agent events during compaction
Manual compaction already waits for the active agent run to settle, and summary generation does not emit Agent events. Keep the agent subscription connected so unexpected concurrent events are not dropped, and remove the obsolete reconnect helper.
closes#7253
Images produced by tools (extensions, MCP bridges, screenshot tools) went into
session history at full resolution because processImage was only wired to the
read tool and @file CLI attachments. Providers validate every image in the
request, so one oversized image poisons the whole conversation: Anthropic drops
its per-image cap from 8000px to 2000px once a request carries many images, and
every later turn re-sends the same payload. Switching models does not help.
Normalize tool result images in AgentSession.afterToolCall, after the extension
tool_result hook so extension-injected images are covered too. Honors
images.autoResize, and keeps the original block when processing fails so an
unavailable image backend does not delete tool output.
Refs #5369
Assisted-By: devx/86bf3b09-9aba-4d03-8154-50fca3ffc9b5
Start forced availability rebuilds independently and discard stale snapshot and error publication. This fixes#7301 and reuses the implementation from #7421 by @a-yeyang with expanded race coverage.
* fix(coding-agent): guard tree navigation during responses
* fix(coding-agent): simplify tree navigation regression
* fix(coding-agent): abort active run on session replacement and tree navigation
Session replacement (resume, new, fork, import) now settles the active
response in teardownCurrent before disposing the outgoing session, so the
aborted turn and its tool results persist instead of leaving a dangling
tool call. Tree navigation aborts the active response directly once the
user commits, without a confirmation gate.
Typing a model name in the /model selector only clamped selectedIndex to
the filtered list length, leaving the highlight wherever it happened to
be instead of moving to the best match. Reset selectedIndex to 0 when a
non-empty query is present so the top row is highlighted in both the All
and Scoped tabs. Keep the clamp behavior when the query is cleared.
fixes#7209
fixes#6647
compaction (auto & manual) and branch summarization retry on transient failures.
use the same retry policy from settings.
emit events for the tui to show indication of retries
* add usage info to branch summary entries
* add usage to compaction entries
* allow custom tools to report llm usage in tool results
* allow observing and patching usage in tool_result hooks
* agent-harness: save usage in entries
for compaction, branch summaries and tool results