* fix(sandbox): show virtual paths in local grep match lines
LocalSandbox.write_file stores host paths in code files so a script runs
under a host interpreter. grep translated the match path back to a
virtual path but returned the matched line as stored, so every grep hit
in such a file showed the host path, including the user's home directory
and the thread directory.
find_grep_matches gains a display_line hook that rewrites a matched line
before it is shortened, and LocalSandbox passes its reverse path
resolution for both the mount walk and the regular walk. The pattern
still matches the stored text.
* fix(sandbox): keep grep line paths spelled as stored
The output path scanner stops at punctuation such as ':' and '(' that
can belong to one filename. Reverse resolution canonicalized the cut-off
prefix, so an unrelated symlink there (cache -> data) turned a stored
reference to cache:old.txt into data:old.txt, a file that does not exist.
Matched grep lines now replace each mount's host root with its virtual
path and keep the tail verbatim, which is what the line says. Bash output
and read_file keep their existing reverse resolution.
* feat(coordination): persist worker run settings
Refs #8533
* test(persistence): update coordination migration head
Keep the single-head migration regression aligned with revision 0060 and assert the new edge to the existing grant revision.
---------
Co-authored-by: ZcWang <200940025+hajicheng@users.noreply.github.com>
* fix(agents): project MCP images for text-only models
Pass configured vision capabilities into request content compatibility for
lead and subagent chains. Replace image inputs with a text placeholder
for text-only model requests while retaining original tool/checkpoint data.
Cover the real graph and SDK HTTP payload, async projection, vision controls
and release-policy fingerprints in the existing compatibility suite.
Fixes#8538
* fix(agents): replay projected history for OpenAI Responses
* fix(agents): project native Responses images for text-only models
---------
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
* fix(memory): keep a sharer's restated details out of the visitor's memory
When a visitor asks about a copied share ("summarize this conversation"),
the assistant's reply restates the sharer's details, and extraction recorded
them as the visitor's facts. Memory capture now marks the visitor's queued
turns when the thread is a share copy, and DeerMem tells extraction that
details repeated from the copy belong to someone else.
Compaction removes the copied messages and their import marks, so run
admission also flags share copies in a server-owned runtime context key.
* fix(memory): flag share copies on manual compaction and when admission cannot read metadata
Manual compaction does not pass run admission, so its memory flush lost
the share-copy flag once compaction had removed the copied turns. The
route now reads the thread's share provenance and passes it on.
A failed admission metadata read returned the same value as an ordinary
thread. The run's later metadata record now decides, and a thread whose
provenance stays unknown is treated as a copy.
* fix(gateway): keep manual compaction working without a thread store
* fix(sharing): keep share provenance in thread state
Share provenance lived in thread metadata and reached memory capture through
a per-run context flag, so every path that derives or rewrites a thread had
to carry it by hand: manual compaction bypassed admission, a branch copied
the state but not the metadata, and a failed metadata read looked like an
ordinary thread.
Share import now writes a server-owned `imported_history` state channel.
Branches copy it, compaction keeps it, and memory capture reads it from the
state it processes, so the run-context flag and its Gateway, worker and
compaction plumbing are gone. Clients cannot write the channel.
Copies imported earlier are migrated before a run, under the manual
compaction's reservation (skipping the memory flush when provenance cannot
be established), and when branched, which marks the copied turns from the
source's import checkpoint. The migration keeps the head's agent binding.
* fix(sharing): keep a copy with unreadable import history out of memory
When the import checkpoint could not be read, the migration still recorded
the copy as resolved, so its unmarked copied turns reached extraction as the
owner's, and later migrations skipped it. Such a copy is now recorded as
unresolved: memory capture and the compaction flush skip it, a branch of it
stays unresolved, and the next run tries the migration again.
* test(sharing): check that turns written while a copy is unresolved are captured later
* fix(sharing): keep memory off for a copy whose import history read fails
A raised checkpoint read now counts as unresolved import history, like a
missing one, so the run records the unresolved marker and memory capture
skips the copy. When the shim cannot store any provenance in a known copy,
the run is refused with a retryable 503 instead of capturing the copied
turns as the owner's.
* fix(artifacts): skip unusable stored rows during consumption tracking
A checkpoint row that merge_tool_artifacts skips can still reach the
consumption scan. Keying every dict by entry["handle"] raised KeyError from
before_model on every later model call, and a non-list consumed_by either
raised or became a character list. Filter the registry the way the reducer
does and treat a non-list consumed_by as empty.
* fix(artifacts): filter invalid handles before capture
---------
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
* fix(harness): compare tool output, not per-call bytes, in loop detection
Loop detection counts a repeated call only while its result is
unchanged, and it hashed the stored ToolMessage content to decide that.
Two common kinds of results change on every call even when the tool
returned the same data:
- langchain-core's create_*_block helpers, which every MCP result goes
through, give each content block a fresh lc_<uuid> id;
- an output that ToolOutputBudgetMiddleware externalizes is replaced by
a preview naming a file derived from the tool call id.
An identical call to such a tool never matched an earlier one, so the
warning and the forced stop never fired and a stuck run went on to the
recursion limit.
A result is now fingerprinted without content block ids, and the budget
middleware records the fingerprint of the output it replaced in its
transform-trail entry (source_sha256), which loop detection compares
instead of the preview.
* fix(harness): keep ids outside standard content blocks in result fingerprints
Only a standard LangChain content block gets a generated per-call id.
A dict of another kind in a ToolMessage list can carry an id that is
the data that changed, so the result fingerprint now keeps it.
---------
Co-authored-by: HYYAlex <232531662+HYYAlex@users.noreply.github.com>
DbRunEventStore kept a strong pin for each thread's asyncio.Lock next to its
weak registry, and released it only in delete_by_thread. Every thread a
process wrote events for, and never deleted, kept a lock and its id for the
life of the process.
The weak registry alone already keeps a lock generation alive while a holder
or waiter references it, which is what the deletion handoff needs. Drop the
pin, as the JSONL store already does.
delete() removed a task after an owner check only. Since the queue
landed, the Gateway deletes through delete_with_queue_cancellation,
which refuses while an occurrence is launching or running and cancels a
queued one. The unguarded method stayed public with no production
caller. Remove it, and cover the remaining delete against real SQLite:
the other-owner, queued and launching cases.
* fix(slack): wait for Retry-After before retrying a reply
chat.postMessage retries at 1s/2s and then drops the reply when Slack
returns HTTP 429. The WebClient default handlers do not retry rate
limits, and the error's Retry-After header was ignored. Wait the longer
of the shared backoff and that hint, capped at 60s per attempt.
* docs(slack): address retry review notes
* docs(slack): drop the changelog hunk
The review of 383a2ec asks to remove the Unreleased entry.
Maintainers add changelog lines at merge time.
* fix(slack): abandon a rate-limited reply when Retry-After exceeds the inline budget
Slack sends run inline on the shared inbound workers, so waiting out a
long Retry-After held a worker other providers need. Cap the inline wait
at 15s; a longer hint re-raises the 429 with a warning instead of
sleeping or retrying early.
* fix(benchmark): honor AIO service flags in Docker lifecycle runs
* fix(benchmark): resolve only selected AIO service flags
* test(benchmark): support skill uploads in the offline OpenSandbox transport
* fix(benchmark): load dotenv before selecting the AIO service profile
close() disposed the process-global persistence engine instead of
anything the repository owns, so a caller cleaning up one repository
would cut off every store in the process. Nothing outside the tests
called it. The tests that opened the engine now close it with
close_engine() directly.
* fix(tools): count todos without a status as pending
* fix(tools): count null todo statuses as pending
* test: stabilize PII redaction scaling check
---------
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
* feat(auth): PAT scopes for agent, schedule and managed-subagent configuration
Opens the routes a deploy pipeline needs to personal access tokens, each
behind its own scope (#8310):
- agents:read / agents:write on /api/agents and /api/agents/{name};
- schedules:read / schedules:write on the /api/scheduled-tasks subtree,
on top of the existing threads:* / runs:create route checks;
- subagents:read / subagents:write on /api/subagents; the writes stay
admin-only and admit an admin's PAT only while it holds subagents:write
(require_admin_user gains an opt-in pat_scope; is_admin_user stays False
for every PAT, so no other admin route changes);
- GET /api/v1/auth/me for any PAT, so automation can confirm its account.
schedules:* and subagents:* are PAT-only scopes enforced by a scoped route
rule in the PAT route policy; session callers are unaffected.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Bas Cancrinus <7222814+bascan@users.noreply.github.com>
* fix(auth): allow PAT mutations for agent names shared by actions
---------
Signed-off-by: Bas Cancrinus <7222814+bascan@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
* feat(task-continuity): add latest-first history search
* fix(task-continuity): order recaptured history by checkpoint
Archive rows retain their original IDs when a batch is recaptured. Use the current checkpoint to rank reachable batches and retain row order within each batch.
---------
Co-authored-by: hajicheng <200940025+hajicheng@users.noreply.github.com>
* fix(sandbox): separate local file tools from shell execution
Signed-off-by: Willem Jiang <willem.jiang@gmail.com>
* test(sandbox): align the bash help assertion
Signed-off-by: Willem Jiang <willem.jiang@gmail.com>
* fix(sandbox): warn about retired local Bash and align guidance
---------
Signed-off-by: Willem Jiang <willem.jiang@gmail.com>
* fix(sandbox): park a boxd machine only when its last claim is released
Two overlapping acquires in one scope record two claims, but the first
release parked the shared machine in the warm pool anyway: its outputs
were mirrored while the second claimant was still mid-turn, and another
caller could reclaim the machine under it (#8382).
_release_scope_locked now decrements the claim count first and returns
while any other claimant is active; only the last release mirrors
outputs and parks the machine. _drop_claim (abandoned async acquires)
uses the same primitive instead of decrementing on its own, so the two
paths cannot diverge.
* fix(sandbox): scope Boxd claims to machine generations
---------
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
* docs: replace links to deleted PRs with commit permalinks (zh changelog, harness reference)
* docs(changelog): repoint deleted PR references to commit permalinks in English changelog
Follow-up to review feedback on #8497: the English CHANGELOG.md still contains the same seven reference definitions pointing to deleted PRs (3823, 3824, 4823, 4825, 4830, 4928, 5047). Apply the same pull/N -> commit/<sha> replacement already done for CHANGELOG_zh.md. Entry text unchanged; all 7 commit permalinks verified to resolve.
---------
Co-authored-by: leom1919 <leom1919@users.noreply.github.com>
* fix(agents): verify reminder provenance before reusing its id
* fix(agents): drop stale persisted reminder before skipping a matching write
* fix(agents): supersede legacy todo reminders, reconcile cleared plans, render items as data
* fix(agents): reject wrapper-only legacy reminders and announce a cleared plan
* fix(agents): replace a stale reminder with the clear notice when the last write is still visible
* fix(agents): skip the clear notice when the last write already cleared the plan
* fix(agents): frame rendered todos as user input data
* fix(agents): frame completion todo text as user input data
Address the Codex P2 on 6adae998: the transient completion reminder
appended unfinished todo text after </system_reminder> without the
user-input boundary markers, so a natural-language directive inside a
todo item was presented with framework trust. The items are now framed
with the same --- BEGIN/END USER INPUT --- markers as the persisted
reminder; _format_todos already neutralizes forged markers inside
item text.
Tests: backend/tests/test_todo_middleware.py 172 passed, including the
new test_completion_reminder_frames_items_as_user_input (verified to
fail on the pre-fix rendering); ruff check and format clean.
* fix(agents): hash persisted todo reminder templates in release policy
release_policy_parameters() hashed only the completion reminder template,
so a wording change to the persisted edited/truncated/cleared reminder
templates left the assembly policy fingerprint unchanged. Hash the three
rendered templates with an empty item list, mirroring the completion
reminder, and add a regression test pinning the new hash entry.
* Merge upstream main into todo-reminder-edited-state
Catch the branch up with upstream main (7b84fd099) to resolve the
merge conflict with main. Conflict resolution:
- backend/tests/test_todo_middleware.py: union of both sides' imports
(keep RemoveMessage from this branch, add ChatGeneration/ChatResult
from main); both are used by the merged file.
All other upstream changes taken as-is, including upstream's removal
of frontend/src/core/voice-input/speech-recognition.ts and its test
in #8286.
* fix(agents): reconcile saved todo reminders on resume
---------
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
* docs(readme): clarify sandbox modes in the Chinese README
* docs(readme): clarify when sandbox Bash is available
---------
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
* fix(todo): address malformed write_todos call ids before results exist
The base TodoListMiddleware builds one error ToolMessage per parallel
write_todos call from tool_calls[*]["id"], and the tool node does the same
for a single call. A missing or non-string id raised a pydantic
ValidationError and aborted the run before the model could retry; empty and
repeated ids created results the next request cannot address, which
backend/AGENTS.md forbids.
TodoMiddleware.after_model now gives those calls synthetic ids and returns the
same message with those ids (the messages reducer substitutes by message id),
so the base hook and the tool node build valid results that pair with the
call. Only structured tool_calls are relabelled; well-formed ids are left
untouched.
* fix(todo): relabel provider tool-call surfaces and reserve other-tool ids
Addresses review on #8354:
- Relabelling is now occurrence-aware and rewrites the provider's own
surfaces (additional_kwargs.tool_calls and tool_use content blocks) as well
as structured tool_calls, so a duplicate id no longer leaves extra blocks
pointing at the old id in the next request.
- Ids used by a non-write_todos call are reserved before a write_todos id is
retained, so a todo call sharing an id with another tool is relabelled and
every emitted result has a unique address.
Tests cover provider surfaces matching the structured ids and a shared
echo/write_todos id; both fail on the previous head.
* fix(todo): preserve tool-call IDs in provider retries
---------
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
* feat(skills): allow injecting storage into activation middleware
* feat(skills): share injected storage across skill consumers
* fix(skills): project injected storage into the lead sandbox
---------
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
* fix(persistence): fence thread status writes by owner in the UPDATE
ThreadMetaRepository.update_status read the row to check ownership and
then updated it by thread_id alone. A row that moved to another owner in
between received the first owner's status. Put the owner condition in
the UPDATE so the check and the write are one statement.
* test(persistence): close the side SQLite connection in the owner-move test
The sqlite3 connection context manager commits but leaves the connection
open, which emits a ResourceWarning on Python 3.13.
* fix(runtime): compose cached delta history in the inner saver's canonical order
_channel_writes() re-sorted a checkpoint's pending_writes by task_id
only. The canonical per-checkpoint order is writes_sort_key =
(task_path, task_id, idx): InMemorySaver returns pending_writes through
_ordered_writes, which sorts by task_path first, and its native
get_delta_channel_history walk collects with the same order.
A stable task_id-only sort therefore reorders writes on fan-out
supersteps whenever task_path order differs from task_id order, and the
cached history then disagrees with the authoritative walk: an
order-sensitive reducer rebuilds a different value from cache than from
the inner saver.
get_tuple() already hands us the canonical order for every supported
backend (the SQL savers emit ORDER BY task_id, idx), so simply filter
by channel and drop the re-sort.
* docs(runtime): attribute sqlite ordering correctly and bump cache format to v2
Two follow-ups from review:
- _channel_writes() claimed the SQL savers emit ORDER BY task_id, idx.
Only postgres does (array_agg(... ORDER BY cw.task_id, cw.idx));
sqlite's pending_writes_sql has no ORDER BY and load_pending_writes
sorts in Python by writes_sort_key(task_path, task_id, idx). The
docstring now attributes each backend's ordering correctly, and notes
the dropped task_id re-sort broke sqlite the same way it broke
InMemorySaver.
- CACHE_FORMAT_VERSION 1 -> 2: entries composed under the old
task_id-sorted order still pass valid_history_entry (shape-only) and
are keyed identically, so a Redis-backed deployment would keep serving
mis-ordered histories until TTL expiry. The versioned default prefix
orphans them on upgrade. Test pin and both mdx pages updated.
* test(runtime): pin the default prefix assertion to CACHE_FORMAT_VERSION
test_key_prefix_override_wins hard-coded startswith("ckpt-hist:v1:") and
broke when the format version moved to 2. Derive the expectation from
CACHE_FORMAT_VERSION so future bumps do not need to touch this test, and
refresh the fake v1 prefix in the thread-purge test for consistency.
* fix(runtime): attribute the postgres pending-writes order to _load_writes
langgraph-checkpoint-postgres 3.1.3 (pinned in backend/uv.lock) aggregates
pending writes with a bare array_agg(...) in SELECT_SQL -- no ORDER BY -- and
the canonical writes_sort_key order comes from _load_writes sorting in
Python, the same mechanism sqlite uses. The docstring claimed postgres orders
with array_agg(... ORDER BY cw.task_id, cw.idx); that ordered aggregate only
exists in the legacy pending-sends migration. Also record that the dropped
task_id re-sort broke postgres the same way it broke sqlite/InMemorySaver.
* fix(runtime): purge legacy Redis checkpoint history on thread cleanup
* docs(checkpoint-cache): clarify no-TTL purge residue
---------
Co-authored-by: laoyyu <laoyyu@users.noreply.github.com>
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
* fix(history): retain recaptured batches in checkpoint order
* fix(history): derive archive retention from checkpoint state
---------
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
* fix(sandbox): build the bash cwd prefix for the shell that runs it
* fix(sandbox): stop when the shell cannot enter the workspace
`Set-Location` reports a missing directory as a non-terminating error, so the
semicolon-separated command still ran — from whatever directory the gateway was
started in. Add `-ErrorAction Stop` so a vanished workspace aborts execution the
way the POSIX `&&` form does, and add a regression test that also proves the
command runs when the workspace exists.
Pin the shell in the remaining POSIX-only prefix assertion so the test no longer
depends on the host shell.
* fix(sandbox): preserve Windows workspace paths at launch
---------
Co-authored-by: huyengiang101086-spec <270684046+huyengiang101086-spec@users.noreply.github.com>
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
`mutate_run_inputs` calls `_next_change_seq` and drops the return value. It
is the only one of the sixteen call sites in that module that does not
assign it, and the only column the method writes is `run_inputs_json`, so
the position it takes never reaches a row: after one append the clock moves
1 -> 2 while the run row's `change_seq` stays at 1.
The clock is a single row, so that write is not free: every queued or
steering message -- `RunInputs.submit`, `acknowledge` and `close` all land
here, and `POST /api/runs/{id}/inputs` reaches it once per message -- buys a
position nothing reads while serializing against every other run mutation in
the database, and against every other writer on SQLite. Progress snapshots,
lease heartbeats and deletes already stay off the clock for the same reason
(#5516), and an append that rewrites one JSON column which no changed-run
cursor observes belongs with them.
The append still reads the row before it writes it, so SQLite needs its
write lock up front; the clock bump had been supplying that as a side
effect. `BEGIN IMMEDIATE` takes it directly, matching `delete` and
`delete_by_thread`. Removing the clock without it would trade a wasted write
for lost updates -- eight concurrent appends leave one item behind and
report no error.
* fix(github): separate webhook runs from tool authentication
Signed-off-by: Willem Jiang <willem.jiang@gmail.com>
* docs(github): explain App authorization for MCP
Signed-off-by: Willem Jiang <willem.jiang@gmail.com>
---------
Signed-off-by: Willem Jiang <willem.jiang@gmail.com>
* feat(extensions): add a workspace page to the run postmortem example
The plugin now declares a PluginContribution: one page surface served from
packaged assets plus three actions (latest, report, markdown) over the same
service and derivation as the HTTP routes.
The page prefills the current thread, loads the latest run the caller owns,
renders verdict, anomalies, activity and a scrollable timeline, and
downloads the Markdown report. A run the caller does not own answers
{"not_found": true} rather than the action route's generic 422.
The extension manifest id becomes the plugin namespace, the frontend
catalog entry follows it, and the bundled documentation snapshot is
regenerated.
* fix(extensions): keep the postmortem page's thread prefill claim conditional
The only page mount point today renders surfaces without a thread id, so
SurfaceContext.threadId is undefined there; the page keeps supporting the
optional field but the README and the module comment no longer promise a
prefill the host cannot deliver.
Also pin `loaded.plugins == ()` in both "nothing registered" tests so a
future reorder cannot surface the sidebar page for a disabled extension.
* test(runtime): control lease expiry during atomic admission
* fix(extensions): make the postmortem's latest run and timeline honest about bounds
The changed-run feed is ordered by change sequence across every thread in
the evidence grant, so a bounded scan cannot prove a run is the newest.
Only a scan that reached the end of the feed may answer a run; an
incomplete scan now answers complete=false, and the page asks for a run ID
instead of presenting an older run as latest.
The page also reveals timeline events in 400-row chunks with "Show more",
so every event in the response is reachable; the banner no longer tells
users to raise Max events when the display cap was the limit.
---------
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
FileMemoryStorage kept one deep-copied document per (user, agent) scope it
had ever read, with no cap. A scope that is only read is never evicted, and
GET /api/memory accepts any well-formed agent_name, so one user could grow
the cache by a document per request for the life of the process.
The cache is now least recently used with a cap of 256 scopes. A hit or a
write refreshes its scope, and an evicted scope is read from its files again.