Commit graph

5411 commits

Author SHA1 Message Date
Christian Klotz
05bf9df651
feat: remove legacy server implementation (#7614) 2026-08-04 20:03:37 +03:00
David Brailovsky
4b85cd9786 harness-v2 mark task in progress 2026-08-04 15:08:44 +00:00
Mario Zechner
44289550aa feat(agent): promote durable harness API 2026-08-04 17:01:43 +02:00
Cristina Poncela Cubeiro
f119b01cb1
refactor: update sqlite for lanes (#7591)
* feat: align sqlite storage with session lanes

* fix: delete lane from entry, action

* fix: errors and types

* fix: tests

* fix: usage records instead of session materialized

* chore: 1 mig

* fix

* refactor(agent): move harness experimental changes to split branch

* refactor and cleanup

* fix: use assertJsonSerializable for session metadata

* fix(sqlite): reject corrupt lane leafs on open

* fix: rebuild cache

* refactor: branch cache

* feat: session stats

* fix: enforce leases

* feat(agent): enforce fenced SQLite writer leases

* fix(agent): keep SQLite transactions synchronous

* fix(agent): align SQLite storage with conformance suite

---------

Co-authored-by: Christian Klotz <hello@christianklotz.co.uk>
2026-08-04 15:56:56 +02:00
Mario Zechner
04133eb01b docs(agent): remove superseded design docs 2026-08-04 15:19:23 +02:00
Mario Zechner
4756e7d122 docs(agent): make harness v2 telemetry self-contained
Section 18 no longer references observability.md, which described the
superseded ALS/global-context mechanism and is being removed. Absorbed
the two load-bearing points: the multi-runtime rationale for rejecting
ambient context (explicit arguments are the only portable abstraction),
and the adapter framing - the application supplies ExecutionContext to
bridge spans into OTel/Sentry/logs/metrics, pi ships no exporter and no
vendor dependency, adapters allocate their own span/trace ids, and may
use AsyncLocalStorage internally. Dropped the reading-list entry.
2026-08-04 15:14:30 +02:00
Mario Zechner
b68decede0 docs(agent): fix coherence defects found by independent review
Full-document review by a fresh-context subagent found 2 blockers, 15
minors, and 12 nits; a second subagent verified every fix. All applied:

- autoCompact ran before_compaction only when no step was unfinished,
  making the hook unreachable on the live overflow path where the
  abandoned assistant step still occupies LaneState; now keyed on
  "not resuming a compaction step".
- Hook-supplied overflow compactions wrote no step_attempt, so the
  once-per-input guard never counted them and hook-driven compact-and-
  retry was unbounded; for reason overflow the hook path now writes the
  compaction step_attempt first.
- Empty compaction preparation is a real code branch, terminal for
  overflow. before_resume is invoked in the resume() dispatch. Pending
  deferred re-park verifies handle equality. resume() re-tags operation
  results as ResumeResult. MessageEntry declares terminate; options gain
  toolExecution; before_navigation loses its orphaned result fields;
  AbortRequestedRecord loses its unreachable reason field.
- Reduction bullets restated (newest-attempt closure, newest-own entry);
  Tier B records lane moves and covers the overflow and cancellation
  traces; hook-measured usage is written as hook ledger records at all
  three append sites; assorted stale wording from before the deferred-
  closure, ledger, and B2 changes brought current.
2026-08-04 15:07:26 +02:00
Vegard Stikbakke
97f0ccdd96 fix(coding-agent): recursively merge nested settings, closes #7572 2026-08-04 13:04:02 +02:00
Vegard Stikbakke
d3da2e968a fix(ai): test composite OAuth refresh cancellation 2026-08-04 13:01:11 +02:00
Mario Zechner
686f193e51 fix(ai): separate deferred request options 2026-08-04 12:45:00 +02:00
Mario Zechner
f24ab6e14c fix(tui): honor nested stack minimum sizes 2026-08-04 12:44:59 +02:00
Vegard Stikbakke
720f0e8eeb fix(ai): route Copilot Grok 4.5 through Responses, closes #7560 2026-08-04 12:42:01 +02:00
Vegard Stikbakke
e741cb05ca fix(coding-agent): preserve extension auth endpoints
closes #7579
2026-08-04 12:37:02 +02:00
Vegard Stikbakke
42a06f9477 fix(coding-agent): test composite OAuth cancellation signal 2026-08-04 12:36:04 +02:00
Vegard Stikbakke
b784c80961 fix(ai): remove OAuth refresh lock test 2026-08-04 12:19:19 +02:00
Vegard Stikbakke
acbdc0d25e fix(ai): bound OAuth refresh duration
closes #7508
2026-08-04 12:12:32 +02:00
Mario Zechner
f7ea2ef38c docs(agent): resolve open questions, add mechanical test constructions
- Tier B: executable append-only-context assertion - every request in a
  run extends the previous request as an exact prefix, except across a
  compaction entry.
- Tier C: crash sites derived mechanically - snapshot the backend after
  every executeAction() of each section 6 trace, reopen and resume every
  snapshot, run recovery twice per snapshot.
- Section 15: fixed-point self-check as a production rule - after every
  resume() outcome, recompute the section 7 reduction and compare to live
  LaneState; mismatch faults the harness. Matching Tier C invariant.
- Section 19 becomes "Resolved questions": per-lane hook registration
  rejected (harness-global with lane field stands); replication stays out
  of scope - the append-only single-writer log replicates by log shipping
  if ever wanted. Cross-references in sections 1 and 11 updated.
- Section 21: implementation goes to src/harness/experimental/ with tests
  in test/harness/experimental/; everything under src/harness/ outside
  experimental/ is removed when the experimental implementation replaces
  it wholesale.
2026-08-04 12:06:53 +02:00
David Brailovsky
382aa641cc
DRAFT: add openai background mode responses (#7339)
* initial attempt at implementing openai background responses api

* feat(ai): align deferred responses with harness spec

* fix: reject deferred messages in protocol v1
2026-08-04 11:27:47 +02:00
Vegard Stikbakke
ab5f8d88ee fix(coding-agent): retain heterogeneous auth model types
closes #6768
2026-08-04 11:05:27 +02:00
Vegard Stikbakke
18d65de623 fix(coding-agent): preserve Copilot summary endpoint
closes #6768
2026-08-04 11:00:30 +02:00
Mario Zechner
221a842c13 fix(coding-agent): update undici to 8.9.0 and brace-expansion to 5.0.9 for npm audit advisories
Resolves GHSA-8xcm-r25x-g524, GHSA-4cwx-7wf7-3272, GHSA-m8rv-5g2x-5cg5,
GHSA-jr45-8vmc-qm54, GHSA-v3r7-h72x-cjcm, and GHSA-rgw5-rvv9-x895.
undici 8.10.0 is blocked by the npm min-release-age gate; 8.9.0 is the
first fixed 8.x release. Reviewed undici 8.6.0-8.9.0 release notes
against http-dispatcher usage; no breaking changes. Adds an AGENTS.md
rule requiring changelog review for future undici updates.
2026-08-04 10:50:54 +02:00
Cristina Poncela Cubeiro
cd20a8d2e5
refactor(agent): split harness experimental changes (#7587) 2026-08-04 10:34:15 +02:00
Vegard Stikbakke
0524d6897f fix(coding-agent): prevent flaky RPC prompt tests 2026-08-04 09:50:42 +02:00
Christian Klotz
1d0c974713
feat(agent): implement harness v2 for in-memory storage (#7503)
* feat(agent): add experimental in-memory sessions

* fix(agent): align session entry ID provisioning

* fix(agent): align v4 compaction entries

* fix(agent): persist tool-result termination decisions

* feat: compaction reason

* fix: get rid of deleteLane

* fix(agent): align lane record schema

* fix(agent): separate lane moves from record appends

* fix(agent): validate durable session payloads

* fix(agent): align lane record type names

* feat(agent): add session backend conformance suite

* Add `undefined` value case to conformance test

* fix(agent): centralize session query validation

* Rename to `SessionRepo`

Rename to `InMemorySessionRepo`

* fix(agent): align in-memory sessions with harness v2

---------

Co-authored-by: Cristina Poncela Cubeiro <140309543+cristinaponcela@users.noreply.github.com>
2026-08-04 10:24:43 +03:00
Vegard Stikbakke
95249a7270 fix: repair tests after model refresh cancellation changes
Follow-up to fed6009cc.
2026-08-04 09:14:16 +02:00
muyiyr
f27aaf66c0
docs(coding-agent): document streamSimple hook contract (#7576)
closes #7372
2026-08-04 08:44:41 +02:00
Vegard Stikbakke
e8a17822de
fix(tui): correct terminal progress clear sequence (#7581)
Co-authored-by: Felix Rath <felixm.rath@gmail.com>
2026-08-04 08:44:00 +02:00
github-actions[bot]
bd3440e5b9 chore: approve contributors from issue #7565 2026-08-04 06:29:54 +00:00
github-actions[bot]
a96fb984d8 chore: approve contributors from issue #7554 2026-08-03 22:50:31 +00:00
Petr Houška
523b5a4917
fix(coding-agent): normalize find root results (#7569)
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
2026-08-04 00:05:48 +02:00
Duncan Ogilvie
25a2c8dcfe
Add support for generic sampling parameters (#7568) 2026-08-04 00:05:29 +02:00
Mario Zechner
fed6009cc9 fix(coding-agent): make model refresh cancellation caller-owned
Add generation-safe catalog publication, cancellable auth and storage operations, locally consistent credential mutations, and cache-first interactive model flows.
2026-08-04 00:03:52 +02:00
Duncan Ogilvie
b06dc76fd7
fix(coding-agent): reinstall dependencies if git clean fails (#7570)
On Windows some files might be held open causing `git clean` to error.
This would leave the extension in a broken state and fail next startup.
2026-08-04 00:02:49 +02:00
Mario Zechner
a0014c1a83 docs(agent): finalize harness v2 on the effects variant
Choose the effects variant as the harness v2 design: rename
harness-v2-effects.md to harness-v2.md with the decision rationale, delete
the rejected generator variant (preserved at 01eeafd1).

Fold in everything decided since the split:

- run/turn/step nomenclature and XxxRecord suffixes for op-log records
- restore rework decisions: TaggedError/matchError result surface, section
  18 ExecutionContext telemetry contract (with in-effect usage example),
  step_attempt.resultEntryId with stable structural ids, hook-durability
  wording, Models-level deferred API, typed record plumbing
- context-overflow/length handling per the superseding PR-7540 review:
  isRecoverableLength against the intended output cap, discard-don't-append,
  one recovery per conversational input, decline/nothing-to-compact
  terminal, Responses incomplete_details mapping, neutral truncation
  wording, crash-site table and test shapes
- UsageRecord cost ledger: union-shaped record (request/tool/hook/
  adjustment causes), cost durability independent of result durability,
  immutable entry usage snapshots with read-time effective cost,
  lane.recordUsage(), harness-global usage event carrying session totals,
  stats as ledger sum via maintained projection, fork/v3-import rules
- prompt normalization, deferred-fulfillment nuance, overflow guard
  reduction, ledger and overflow test coverage
2026-08-03 23:46:59 +02:00
Armin Ronacher
fa07e7bd92 fix(tui): detect truecolor for Windows consoles 2026-08-03 21:57:44 +02:00
Armin Ronacher
3d264e85b4 fix(coding-agent): avoid terminal query leak on fullscreen exit 2026-08-03 19:18:39 +02:00
Armin Ronacher
c72728bc1a fix(coding-agent): remove obsolete --alt shortcut 2026-08-03 19:00:35 +02:00
muyiyr
da66636cc4
fix(coding-agent): discover sessions through symlinked directories (#7552)
fixes #7497
2026-08-03 18:34:12 +02:00
Christian Klotz
a4475344fb
fix(coding-agent): make JSON streaming output linear (#7394)
Fixes #7290

Co-authored-by: Mario Zechner <badlogicgames@gmail.com>
2026-08-03 18:33:22 +02:00
David Brailovsky
32850ef7c5
fix(coding-agent): resume after context-limited length stops (#7540)
* 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.
2026-08-03 18:07:53 +02:00
David Brailovsky
e56893f4cd
fix(coding-agent): prevent auto-compaction race during manual compaction (#7370)
* 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
2026-08-03 18:00:21 +02:00
Armin Ronacher
b103937d3c
feat(coding-agent): switch UI modes at runtime (#7555) 2026-08-03 17:32:48 +02:00
Armin Ronacher
e563301dd3 fix(ai): avoid stale Copilot model in overflow test 2026-08-03 17:20:49 +02:00
Christian Klotz
305c014dcc
fix: make session authentication transport-specific (#7551)
Set the initial protocol version to 1 and remove bearer authentication from framed messages. Require transports to establish authorized connections.
2026-08-03 16:40:00 +03:00
Ramiz Wachtler
0e633790c5
fix(tui): handle batched color scheme reports (#7550)
- fixes #7538
2026-08-03 15:24:34 +02:00
David Brailovsky
c1019d9202 feat(ai): add Baseten provider
Closes #7405
2026-08-03 14:33:21 +02:00
Vegard Stikbakke
a24fb9e96a
fix(coding-agent): preserve auth header deletion markers (#7539)
Fixes #7030
2026-08-03 14:28:26 +02:00
Armin Ronacher
a8ee03b815 fix(tui): cache recently offscreen Kitty images 2026-08-03 14:03:16 +02:00
Jeremy Gayed
b0e05b4423
fix(coding-agent): resize images returned by tools (#7330)
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
2026-08-03 14:02:03 +02:00
yaogangqiang
0f5286d8ab
feat(agent): expose shouldStopAfterTurn on Agent (#7367) 2026-08-03 14:01:16 +02:00