Commit graph

173 commits

Author SHA1 Message Date
David Brailovsky
81fd74cfc3 fix(coding-agent): run availability passes one at a time with a timeout
An awaited refresh could resolve before its availability pass saved. Passes
ran concurrently, and only the most recently started pass could save its
result; a superseded pass returned without saving and refresh() still
resolved. At startup, the awaited refresh could lose to a fire-and-forget
refresh started by an extension provider registration, so initial model
selection read a snapshot without that provider and fell back to another
provider's default. A login also cancelled any full pass that was running.

Availability passes now run one at a time. A request made while a pass is
waiting to start joins it, so a caller always gets a pass that saw its
changes. Each pass has a 10 s timeout, so a hung auth check or credential
store no longer blocks the caller forever (#7301). A failed or timed-out
provider check keeps that provider's previous state and is reported in
getError().

The snapshot drops configuredProviders and all; hasConfiguredAuth reads
the auth map.

Refs #8810, #9884
2026-09-30 09:21:44 +02:00
Armin Ronacher
9a100c7cc4 feat(coding-agent): report codemode classifier and nested tool usage in session cost
Codemode sums the usage of models.classify() calls into its tool result and shows each call's cost. Usage of tools called through ctx.executeTool() is added to the calling tool's result usage instead of being dropped.
2026-09-29 16:21:39 +02:00
Armin Ronacher
8562bcf66a feat(coding-agent): codemode and MCP
This adds codemode and MCP support to pi. Codemode (packages/codemode) runs
model-written JavaScript in a QuickJS wasm VM inside a worker. From there the
script calls pi's tools as async functions, uses a per-session store, and can
read the model catalog and run classifiers. The codemode tool in coding-agent
is compatible with Codex's exec tool, and codemode.mode works like Codex's
tool modes (on or only). Large results are written to a JSON temp file. MCP
(packages/mcp) is a standalone client for stdio and streamable HTTP servers,
with OAuth.

The core only gets general mechanisms; codemode, tool_search and MCP are
built-in extensions that use them. Other extensions can replace these
built-ins. Tools declare an exposure: direct, model-only, codemode, deferred
or hidden. prepareLoadout() lets an orchestrating tool change which tool
declarations the model sees. ctx.executeTool() runs nested calls through
validation and the tool_call/tool_result hooks. Those calls emit events with
parentToolCallId and are recorded as bounded nestedCalls on the parent
result, which compaction and HTML export use. Tools can also return
structuredContent with an outputSchema, and can report errors with isError
instead of throwing. MCP servers come from mcp.json (global, or per project
after the project is trusted) or from pi.registerMcpServer(). They are
managed with /mcp and pi mcp list|login|logout, and their runtimes load on
first use.

Closes #10040
2026-09-29 09:12:50 +02:00
Armin Ronacher
540e174c72
feat(coding-agent): Virtual models (#10035)
This adds experimental support for virtual models. A virtual model is a catalog entry that an extension registers with pi.registerVirtualModel(). It does not talk to a provider itself; for every request it picks a physical model and thinking level. The motivation is to make routing policies pluggable: plan on a strong model and implement on a cheap one, pick a model with a classifier, or move to a larger window when the context grows. Today this needs model switching by hand or hacks in prepareRequest.

The selection stays virtual: model_change records it, resume restores it, and each response records the physical model and thinking level that produced it. Router state can be stored on the session branch, so it follows /tree and forks and survives compaction. Context limits, compaction and image sizing use the physical model a request was routed to. examples/extensions/jev-router.ts shows a full router that uses the Jev classifier to pick Sol or Terra for planning and hands off to Luna after the first edit. docs/virtual-models.md describes the API.
2026-09-28 23:30:45 +02:00
David Brailovsky
ff72faba28 fix(coding-agent): save new session file at the first user message
A new session was only written to disk once the first assistant message
existed. If pi exited during the first turn (Ctrl+C twice while streaming,
or the process was killed), the user's prompt was lost and the session
never appeared in /resume.

The file is now created as soon as the session has a user or assistant
message. A session with only setup entries (model, thinking level) still
stays in memory, so starting pi and quitting without chatting leaves no
file. Forking uses the same rule through a shared helper, so the two paths
cannot drift apart and write the header twice (#1672).

closes #10000
2026-09-25 16:27:51 +02:00
David Brailovsky
e473b5cd8b feat(coding-agent): report prompt disposition in RPC responses
Successful RPC prompt, steer, and follow_up responses include
data.disposition ("handled", "queued", or "started" for prompt), so clients
know whether to wait for agent_settled.

fixes #9098
2026-09-25 14:53:11 +02:00
David Brailovsky
d192bd6dca
fix(coding-agent): avoid Fable split-turn summary refusals (#9908)
Separate conversation content from instructions and replace prefix/suffix wording with continuation-oriented summarization guidance.

Hopefully this avoids the refusals.

Fixes #9652
2026-09-22 16:52:07 +02:00
Armin Ronacher
aef5fc429b
fix(coding-agent): keep prompt and tool state across context handlers (#9846)
Since 0.86 the prompt and tool declarations live in transcript system
messages, so a context handler that filters or slices messages could drop
them. After extension-driven compaction this sent requests without built-in
tools and made Codex emit raw tool-call text.

context handlers now see the conversation only. An unchanged list keeps the
transcript as is; a changed list gets the replayed prompt sections and tool
declarations as one leading system message. Handler-added system messages
are kept after it.

Add context_with_system, which runs after every context handler on the full
transcript and sends its result verbatim, for extensions that need to edit
system messages per request. Dropping the leading system message is reported
as an extension error.

closes #9789, closes #9822
2026-09-21 17:14:22 +02:00
Mario Zechner
466db0fecd feat: add canonical session context boundaries
Make SessionManager projections authoritative for provider requests, add append-only context edits and actionable turn boundaries, and preserve existing queue scheduling during continuation and recovery.
2026-09-21 16:59:20 +02:00
Armin Ronacher
f5c946480c feat(ai,coding-agent): add image input limits (closes #9631) 2026-09-20 22:59:16 +02:00
Armin Ronacher
40c256cccb feat(coding-agent): defer extension loader dependencies
Load ordinary jiti lazily on Node while retaining jiti/static for Bun and SEA binaries. This closes #9540.
2026-09-19 23:25:47 +02:00
Armin Ronacher
de2de549bc fix(coding-agent): close compaction cancellation races
Closes #9340 and closes #9777.
2026-09-19 19:18:18 +02:00
Vegard Stikbakke
8bdcd4498a fix(coding-agent): compact oversized trailing tool results
Fall back to the latest safe assistant boundary when trailing tool results exceed the retained-token budget, allowing older history to compact before the next provider request.

Closes #9740
2026-09-18 13:38:30 +02:00
Mario Zechner
cf8d5fac30 feat(agent): add Pico storage foundation 2026-09-18 12:32:00 +02:00
Christian Klotz
509ee2bd0b
fix(coding-agent): fail closed on user bash hook errors (#9662)
* fix(coding-agent): fail closed on user bash hook errors

Prevent failed execution-routing hooks from falling back to the local shell.

Fixes #9068

* fix(coding-agent): validate user bash hook results

* docs(coding-agent): clarify user bash result semantics

* docs(coding-agent): streamline user bash semantics

* fix(coding-agent): strengthen user bash regressions

* docs(coding-agent): clarify user bash breaking change
2026-09-16 17:21:17 +01:00
Armin Ronacher
9e05370b29
Mid conversation system messages (#9548)
This change makes system prompt text and tool changes part of the transcript rather than silently rewriting its starting conditions. This lets Pi record when instructions changed or tools became available, restore that state after resuming or navigating branches, and preserve cached prompt prefixes where the upstream supports it.
2026-09-16 15:54:07 +02:00
Vegard Stikbakke
46bde88a1c feat(coding-agent): support per-model compaction token budgets
Closes #8133
2026-09-10 08:37:20 +02:00
David Brailovsky
faa9863cb8 fix(coding-agent): run input handlers for queued messages
Apply input extension transforms and handling to direct steering and follow-up messages while preserving their input source.

Fixes #8718
2026-09-08 17:18:37 +02:00
Ramiz Wachtler
aa23e784c6
fix(coding-agent): update repository links to "earendil-works/pi" (#9278)
- update repository links in prompts, docs, and code to use `earendil-works/pi` instead of `earendil-works/pi-mono`
2026-09-07 14:09:39 +02:00
Ramiz Wachtler
1f78cea7ad
fix(coding-agent): allow extensions to stream from custom providers (#9272)
- fixes #8964
2026-09-07 12:16:12 +02:00
yaogangqiang
e687434a60
fix(coding-agent): reject tree navigation during compaction (#9179)
Fixes #9178
2026-09-07 10:32:10 +02:00
Armin Ronacher
9767ba275f fix(coding-agent): select Radius models after catalog discovery 2026-09-06 00:30:17 +02:00
David Brailovsky
3316c4e35b fix: repair Baseten and coding-agent test checks
Drop the misleading Baseten default-model test and remove a duplicate coding-agent mock declaration rejected by Biome.
2026-09-03 11:40:37 +02:00
wutongyuonce
1a773c8e7a
fix(coding-agent): avoid overwriting imported sessions (#8985) 2026-09-03 10:48:18 +02:00
yaogangqiang
2631b25c34
fix(coding-agent): preserve compaction boundary when forking (#8990)
Fixes #8989
2026-09-03 10:47:40 +02:00
xu0o0
f0592205f8
feat(tui): render relational algebra join symbols & fix(coding-agent): type error in test (#9050)
* feat(tui): render relational algebra join symbols

* fix(coding-agent): update interactive mode test fixture
2026-09-03 10:45:02 +02:00
David Brailovsky
f41f80466e fix(coding-agent): update interactive mode test fixture 2026-09-03 09:53:14 +02:00
David Brailovsky
bea67d90d1 fix(coding-agent): cancel compaction on session abort
Include compaction and branch summarization in session idle tracking so abort waits for cancellation to settle.\n\nfixes #8920
2026-09-03 09:41:55 +02:00
Ramiz Wachtler
f2a6227899
feat(coding-agent): adjust TUI selections in thinking-mode, models and scoped models (#8900)
* fix(coding-agent): keep selector status markers visible

- place status markers before labels
- strike unavailable scoped models and update tests

* fix(coding-agent): align scoped model toggle behavior

- show checks for the all-enabled state
- toggle individual models consistently and add coverage

* docs(coding-agent): add changelog entry

* fix(coding-agent): keep trust marker visible while browsing

- move the saved marker before the trust option
- update tests and changelog

* fix(coding-agent): mark per-model thinking overrides

- add the leading level marker
- update tests and changelog
2026-09-01 11:02:53 +02:00
yaogangqiang
afda4d6202
fix(agent): stop prepared tools after preflight abort (#8936)
fixes #8935

Co-authored-by: yaogangqiang <yaogangqiang@kanyun.com>
2026-09-01 11:00:51 +02:00
yaogangqiang
56c6fb33c4
fix(coding-agent): settle active turn before in-memory fork (#8937)
Fixes #8724

Co-authored-by: yaogangqiang <yaogangqiang@kanyun.com>
2026-09-01 10:58:20 +02:00
David Brailovsky
e54d45d119
docs(coding-agent): remove issue-specific regression test placement rule (#8775) 2026-08-28 16:39:28 +02:00
David Brailovsky
56700d42ed
fix(coding-agent): compact before post-tool model requests (#8782)
Run next-turn preparation only when the agent loop continues, allowing threshold compaction before the next provider request. Restore interactive progress when the same run resumes.

Closes #6879

Important to notice:
this changes when prepareNextTurn & prepareNextTurnWithContext are invoked:
the now run only when a next turn actually happens, and after shouldStopAfterTurn.
2026-08-28 13:40:59 +02:00
Vegard Stikbakke
b07e17faa2 fix(coding-agent): preserve partial Bash output when toggling thinking
closes #8611
2026-08-26 14:27:21 +02:00
Vegard Stikbakke
7af2d27dce fix(coding-agent): prevent Windows taskkill spawn crashes
closes #6596
2026-08-26 10:33:45 +02:00
Mario Zechner
240eb29c41 fix(coding-agent): append run-time custom messages after the turn's tool results
Extension messages sent with triggerTurn: false while the agent was
running were pushed into agent state and the session tree immediately,
landing between an assistant tool call and its result. Providers that
validate message order reject the replayed history. Queue them during
the run and append at turn_end, mirroring recordBashResult.

closes #8537
2026-08-25 12:14:10 +02:00
Vegard Stikbakke
97fa14e39c fix(coding-agent): reject truncated compaction summaries closes #7048 2026-08-24 13:08:30 +02:00
Armin Ronacher
80e62761f7
feat(coding-agent): add optional PowerShell tool (#8512) 2026-08-24 12:27:03 +02:00
yaogangqiang
a69bef789b
fix(coding-agent): discard failed extension factory state (#8424) 2026-08-23 12:39:42 +02:00
Armin Ronacher
74786a748f fix(coding-agent): support -- end-of-options, closes #7269 2026-08-22 23:16:40 +02:00
Cristina Poncela Cubeiro
5133c9284f chore(settings-selector): get rid of --default and global model
ctrl+s is enough, there goes my joy
2026-08-20 13:30:47 +02:00
Cristina Poncela Cubeiro
2ff8ba6223
fix(coding-agent): keep model and thinking level changes session scoped (#8356)
* 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
2026-08-19 16:48:29 +02:00
Armin Ronacher
1355cd36e0 fix(coding-agent): normalize UTF-8 BOMs in text inputs
closes #8337
2026-08-19 14:11:02 +02:00
Vegard Stikbakke
4495469a5e fix(coding-agent): compact without provider usage
closes #8328
2026-08-19 13:44:22 +02:00
Vegard Stikbakke
678f0af30d fix(coding-agent): show startup diagnostics in TUI
fixes #7829
2026-08-19 13:07:57 +02:00
Christian Klotz
830a0a59e9
fix(coding-agent): expose tool metadata at stream start (#7953)
* fix(coding-agent): expose tool metadata at stream start

* fix(coding-agent): centralize message update serialization
2026-08-19 12:24:30 +02:00
Mario Zechner
c061328981 fix(coding-agent): load extensions in Node SEA hosts, closes #8237 2026-08-18 16:48:18 +02:00
Vegard Stikbakke
ef8dc7385b feat(coding-agent): centralize compaction summary requests 2026-08-18 14:19:01 +02:00
Vegard Stikbakke
8af7690c4f fix(coding-agent): skip trusted subagent prompts
closes #8261
2026-08-18 09:26:07 +02:00
Armin Ronacher
b82a374c7d fix(coding-agent): reduce redundant slow tests 2026-08-17 22:57:18 +02:00