1983 Commits

Author SHA1 Message Date
kongxin
ca134bbfb3
fix(sandbox): keep line endings when str_replace edits a file on AIO (#8662)
* fix(sandbox): keep line endings when str_replace edits a file on AIO

AioSandbox.read_file read through the AIO /v1/file/read route, which
returns text with every CRLF and bare CR turned into LF. str_replace
then saw no CRLF, so changing one word in a CRLF file wrote every line
back as LF; CR-only and mixed-ending files were rewritten the same way.
The write route stores "\r" as given, so only the read was lossy.

read_file now reads the stored bytes through the download route and
decodes them as UTF-8, so a full read returns line endings as stored,
as on the local sandbox since #6343. Ranged reads are sliced with
split_file_lines, as on E2B, BoxLite, Tenki and OpenSandbox: the
server's ranges also ended lines at a bare CR, form feeds and Unicode
separators, and would no longer agree with the start_line a truncated
full read suggests.

A missing file, a directory, a file the server cannot open and a
non-UTF-8 file still return "Error: file not found or unreadable". A
file over the 100 MB download limit raises instead: an error string
would let str_replace replace text inside it and write it over the
file.

* fix(sandbox): match str_replace snippets that span mixed line endings

A ranged read joins lines with "\n", so an old_str copied from a file
that mixes CRLF and LF lines matched neither its literal nor its
all-CRLF spelling once read_file returned the stored endings. Match it
against the file with CRLF read as LF and replace only the original
span, so line endings outside the edited text stay as stored; new_str
takes the ending of the span's first line break. HarnessGuard splices
through the same helper.

* fix(sandbox): block writes over an AIO file too large to read back

AioSandbox.read_file raises OSError(EFBIG) for a file over the 100 MB
download limit, so that str_replace never writes an error string over
it. The read-before-write gate caught that exception in its generic
handler and failed open: write_file could replace an existing AIO file
over 100 MB without any read, which the gate blocked before, when the
read route returned the content. On a live AIO 1.11.0 container,
write_file replaced a 110 MB file that had never been read.

No read can ever mark such a file, so the gate now returns a blocked
result for EFBIG, with the usual write-block metadata, telling the model
to use bash instead. This covers write_file, appends and str_replace, on
the sync and async paths. Other inspection errors still fail open, and
a new file is still created.

* fix(sandbox): copy only the selected lines in an AIO ranged read

A ranged AIO read_file split the whole downloaded file into a list of
every line before slicing. On a 100 MB file of short lines one read
peaked at about 2 GB of extra memory in the Gateway; on main the server
sliced ranges itself.

slice_file_lines returns the same text as joining the split_file_lines
slice, with the same clamping, but counts newlines block by block and
copies only the selected lines. The same read now needs a few kilobytes
and runs in under 0.1 s instead of 1-5 s. A property test checks it
against the split-and-join result on random content.

* fix(sandbox): match str_replace snippets in file order whatever their line endings

str_replace tried the literal and the all-CRLF spelling of old_str over
the whole file before it looked for a snippet that spans CRLF and LF
lines. When a ranged read spanned mixed endings and the same text
recurred later with LF only or CRLF only, a default edit changed the
later copy and returned OK, and replace_all left the mixed copy alone.
The offset table behind the mixed search also kept one integer per CRLF
in the file: 1.6 GB of extra memory for one edit in a 100 MB file of
short lines.

The matcher now has one rule instead of fallbacks. In a file with CRLF,
a CRLF is one line break; a "\r\n" in old_str matches only a CRLF, a
"\n" matches either ending, and every other character matches itself.
Matches are taken in file order without overlapping, as str.replace
takes them. The n-th line break of new_str is written in the ending of
the n-th line break inside the match, so an edit that keeps the line
count keeps every line's ending, and no match splits a CRLF. A file
without CRLF is still matched literally, and a file whose breaks are all
CRLF, or an edit without line breaks, still runs as one str.replace,
which the tests show gives the same result. Match boundaries are mapped
by counting CRLFs forward from the previous match, so the extra memory
stays near three times the file (the CRLF-as-LF copy and the output)
whatever its newline density: 292 MB for that edit instead of 1.6 GB.
An empty old_str is a no-op here too, so the HarnessGuard syntax check
no longer blocks an edit that str_replace would not make.

Tests: a hypothesis reference model of the rule on files that mix
"\r\n", "\n" and "\r", with snippets from ranged reads, full reads and
typed text; parity with main on files with one ending; ranged-read
snippets are never reported missing; the real str_replace and the
HarnessGuard splice against the model. The AIO tests now run the real
agent_sandbox client over an httpx transport that serves the download,
read and write routes as AIO 1.11.0 does, including the ordering cases
and the oversized-file gate.

* fix(sandbox): keep ranged reads and str_replace matching linear

A ranged read dropped the carriage returns that end each line with the
regex \r+(?=\n). On a run of bare \r followed by ordinary text the
lookahead failed and the search retried from every \r of the run, so the
read was quadratic in its length: 15 s for an 80,000-character run
through the AIO SDK. The same sub also built a list with two entries per
CRLF line, 220 MiB for a ranged read of a 10 MB CRLF file. The read now
turns each \r\n into \n with str.replace, and only when a line ended in
several \r does it cut each run with one find and rstrip per such line,
writing to a StringIO. Every character is read a fixed number of times,
and the result equals joining the split_file_lines slice as before.

The str_replace matcher had the same class of problem. A snippet with
\r\n was searched with CRLF read as LF and each overlapping candidate was
then checked position by position, so a CRLF snippet over many LF lines
cost the file length times the snippet length. Accepting a snippet whose
\r\n and \n may land on any mix of endings is a subset match, which no
forward scan does, so a snippet with \r\n now matches as written or with
every line break spelled CRLF, the two spellings main tried, in file
order; a leading \n may also be the LF of a CRLF, since such a snippet
cannot show the ending of the line before it. A snippet without \r\n,
as a ranged read or the model writes it, still matches with each \n as
LF or CRLF. Each spelling is found with str.find; only a spelling that
ends in a bare \r and occurs right before an LF uses a regex, whose
literal prefix re scans with a KMP overlap table, so candidates that
would split a CRLF are skipped without rescanning them.

Tests: a growth check (tests/support/scaling.py) compares the thread CPU
time of a 16x larger adversarial input with a small one and requires
under 64x, where linear is about 16x and quadratic 256x. It covers CR
runs, CRLF and multi-CR lines for ranged reads, through the real AIO SDK
too, and rejected candidates, CR runs and replace_all with many matches
for the matcher. The old code fails it at 180x to 277x, a find-and-retry
finder at 300x to 400x, and it passed 72 of 72 runs with the CPU four
times oversubscribed. The reference model follows the new rule, a
full-read snippet that does not split a CRLF is never reported missing,
and the ranged-read property test draws runs of \r.
2026-11-27 22:07:26 +08:00
Kevin Hsiao
4b6af76252
docs(vefaas-sandbox): add DeerFlow UTM parameters and complete remaining veFaaS doc coverage (#8719)
* docs(vefaas-sandbox): append DeerFlow UTM parameters to BytePlus veFaaS links

* docs(vefaas-sandbox): complete veFaaS coverage in CONFIGURATION.md, deployment guides, and ZH configuration docs
2026-11-27 21:59:38 +08:00
Wistom Zhang
46493c31f8
fix(memory): rescue at-risk reserved facts below eviction cap (#8331)
* fix(memory): rescue at-risk reserved facts below eviction cap

* fix(memory): draw hybrid reserve from ranking tail to keep repeated writes bounded

---------

Co-authored-by: Totoro <msy626836554@gmail.com>
2026-11-27 19:30:41 +08:00
Kevin Hsiao
6e737805e8
feat(byteplus-agentplan): integrate BytePlus Agent Plan across LLM, Seedream, and Seedance 2.5 skills (#8701)
* feat(byteplus-agentplan): integrate BytePlus Agent Plan across LLM, Seedream, and Seedance 2.5 skills

- Add `byteplus_agentplan` provider to `skills/public/video-generation` for
  Seedance 2.5 (`dreamina-seedance-2.5` / `dreamina-seedance-2.5-flash`) with
  multi-reference image support, native audio generation, same-origin redirect
  enforcement, BytePlus TOS download allowlist, and clear tier-upgrade guidance
  on HTTP 403 rejections.
- Add `byteplus_agentplan` provider to `skills/public/image-generation` for
  Seedream (`dola-seedream-5.0-pro` / `5.5` / `5.0-flash`) with JSON reference
  images and safe decode-before-write handling, powering `ppt-generation` with
  the same API key.
- Register `byteplus-agent-plan` in `managed_model_providers.py` and
  `byteplus_agentplan` in the interactive `make setup` wizard (auto-forwarding
  `BYTEPLUS_AGENTPLAN_API_KEY` into `sandbox.environment`).
- Update `.env.example`, `provider_credentials.py`, `config.example.yaml`,
  READMEs, skills guide, and Ark model-provider docs.

* fix(byteplus-agentplan): address review feedback on vision, Seedream prompt/format/aspect ratio, and test return flow

* docs(byteplus-agentplan): append DeerFlow UTM parameters to BytePlus Agent Plan console and doc links

* fix(byteplus-agentplan): require opt-in for sandbox key sharing and validate Seedream images before writing
2026-11-27 17:00:09 +08:00
ZedingZhang
3b246c9426
fix(threads): keep failed branch checkpoints tied to an owner (#8682)
* fix(threads): keep failed branch checkpoints tied to an owner

Reserve the child and persist its metadata before copying the replay base and head. Reconcile a lost insert acknowledgement and keep the ownership row until checkpoint rollback succeeds.

* fix(threads): fence branch writes after child reservation loss

Confirm the child admission before each insert, checkpoint write, and rollback step. Drain each operation individually so a cancelled request can finish its current write without starting another after a takeover.

Exercise ownership loss during the insert, replay-base write, failing head write, and checkpoint cleanup with two RunManagers sharing SQLite.
2026-11-27 13:55:27 +08:00
Bas Cancrinus
818eaf16f2
feat(sandbox): structured run error and UI toast for sandbox capacity (#8697)
* feat(sandbox): structured run error and UI toast for sandbox capacity

A run that acquires its sandbox before the model runs fails with
SandboxCapacityExceededError when the provider has no capacity. The
run error event carried only message and name, so clients parsed the
code and retry hint out of the text and the UI showed the raw message.

The error event now adds code, retryable and retry_after_seconds for
errors with a structured details dict, and the web UI says the
sandboxes are busy and to try again shortly.

Refs #8586

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Bas Cancrinus <7222814+bascan@users.noreply.github.com>

* fix(sandbox): omit non-finite retry hints; neutral sandbox-unavailable toast

Review on #8697: a NaN or infinite retry_after_seconds would be written as a
bare token the LangGraph SDK rejects, losing the whole error frame; it is now
omitted while code and retryable still arrive. The toast no longer claims
every sandbox is busy: the same error appears while a provider's capacity
store is initialising or shutting down.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Bas Cancrinus <7222814+bascan@users.noreply.github.com>

* docs(api): document structured SSE run errors

---------

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>
2026-11-27 13:50:23 +08:00
Eason Meng
62a1f91ff2 fix(github): enforce fail-closed author authorization on webhook triggers
Require GitHub webhook actors on user-authored events to match either
allow_authors (with optional allow_authors_bypass_mention control) or
allow_author_associations (defaulting to OWNER, MEMBER, COLLABORATOR)
verified against sender.login == authored.user.login. Guard non-object
JSON bodies and non-dict sender payloads, and align redundant review
comment suppression with review trigger authorization.

Signed-off-by: Eason Meng <eason.meng@bytedance.com>
2026-11-27 11:35:57 +08:00
Loveca
9157cf1293
fix(sandbox): strip the provisioner API key on both sides of the shared secret (#8651)
* fix(sandbox): strip the provisioner API key on both sides of the shared secret

A PROVISIONER_API_KEY mounted from a file-backed Kubernetes Secret keeps
its trailing newline. The Gateway sent the raw value as X-API-Key, which
requests refuses before sending with an InvalidHeader message that quotes
the whole key; the message was logged and re-raised into the model-visible
tool error string. The provisioner compared the raw env value too, so a
key polluted with trailing spaces answered 401 on every /api/* request.

Strip surrounding whitespace from the configured key on both sides. The
provisioner image is standalone and cannot import provider_credentials,
so each side strips inline; placeholder semantics stay unchanged. Scrub
the configured key from all six provisioner error exits, in both raw and
repr-escaped spelling, and re-raise with from None so the unredacted
transport exception cannot survive in the cause chain.

Fixes #8650

* test(sandbox): pin the discover redaction caplog to its own logger

caplog.at_level(DEBUG) without a logger name only lowers the root and
handler levels; a prior test that leaves the deerflow logger at INFO
(configure_logging does not restore it) drops the DEBUG record before
it reaches the capture handler. Name the logger so the level is set and
restored on the emitting logger itself, matching test_aio_sandbox.py.

* fix(sandbox): keep health-check bodies out of the provisioner error

The non-2xx branch of the provisioner health check appended the upstream
response body to the RuntimeError. _check_tracked_sandbox_alive logs that
error, so a body that echoes request headers or carries proxy diagnostics
would bypass the transport redaction added for the API key fix. Report the
operation and status code only; the 404 and JSON branches never read the
body.
2026-11-27 11:03:08 +08:00
Kevin Hsiao
a92a87b964
docs(vefaas-sandbox): surface BytePlus veFaaS cloud sandbox across docs, env template, and landing page (#8702) 2026-11-27 09:04:41 +08:00
HeZzz
e45da192fe
fix(models): honour fractional and retry-after-ms hints in Claude retries (#8656)
`ClaudeChatModel._calc_backoff_ms` parsed `Retry-After` with `int()` and
never read `retry-after-ms`, so a decimal hint from a gateway raised,
fell through to HTTP-date parsing, and was dropped. The retry then used
the local 2.4 s schedule and could spend its budget inside the same
throttle window.

Move the header parser into `utils.retry_after.retry_after_hint_ms`
(spellings, float seconds, ms units, HTTP-date fallback, 24 h bound) and
use it from both the Claude and Codex providers, keeping each caller's
clock for HTTP dates.

Fixes #8655
2026-11-27 09:01:16 +08:00
zmjj-kk
f189099c09
feat(scheduler): enable subagents for scheduled tasks (#8598)
Persist an opt-in for automatic and manually triggered scheduled runs.
Carry unattended guidance through ordinary and durable delegation, and
keep continuation discovery separate from batch argument validation.

Cover the Gateway-to-worker path, including queued batches recovered
after restart, and add the opt-in with Alembic revision 0062.

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2026-11-27 08:55:21 +08:00
Totoro
e0886e9677
fix(agents): preserve reasoning choices across model and chat switches (#8698)
* fix(agents): preserve reasoning choices across model and chat switches

Apply inherited thinking after selecting the model so a required-thinking profile can admit the run. Keep explicit disable requests subject to the profile policy. Read manual effort choices from the current thread for both the composer and the submitted request.

* fix(frontend): clear stale chat effort on model fallback

Validate a saved chat effort when the composer resolves its current model. Keep supported choices in the same chat and release an obsolete override even if another chat has already resolved the shared fallback.

---------

Co-authored-by: Totoro-qaq <279883115+Totoro-qaq@users.noreply.github.com>
2026-11-27 08:46:08 +08:00
ZephyrWang
0890e94e84
fix(skill-review): report invalid YAML timestamp values (#8695)
* fix(skill-review): report invalid YAML timestamp values

* Handle malformed explicit YAML timestamps in skill frontmatter

---------

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2026-11-27 08:42:22 +08:00
Bas Cancrinus
349540c13f
fix(subagents): keep batch item token usage across attempts (#8647)
* fix(subagents): keep batch item token usage across attempts

finalize_item replaced the item's token_usage with the finishing attempt's
usage, so a retried item kept only its last attempt and the exception path
(token_usage=None) erased what was stored. Add each attempt's counts to the
stored total instead.

Refs #8646

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Bas Cancrinus <7222814+bascan@users.noreply.github.com>

* fix(subagents): keep an attempt's token usage when its finalize fails

When the finalize that carried an attempt's usage raised (for example a
rolled-back commit), the exception handler finalized the item again with
token_usage=None, so that attempt's tokens were lost. Carry the collected
usage and model name into that call. If the first finalize did commit,
the lease is already released and the second call writes nothing, so
nothing is counted twice.

Refs #8646

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Bas Cancrinus <7222814+bascan@users.noreply.github.com>

---------

Signed-off-by: Bas Cancrinus <7222814+bascan@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 22:40:19 +08:00
Totoro
c0eefedc4f
fix(scheduler): canonicalize one-time task timestamps at the Gateway boundary (#8675)
Keep explicit instants in UTC and offset-free times in the task zone. Apply the same representation to historical reads while preserving no-op edits and the original execution time.

Co-authored-by: Totoro-qaq <279883115+Totoro-qaq@users.noreply.github.com>
2026-11-26 22:36:38 +08:00
Hazenix
5758c1034e
feat(runtime): support attachments in queued Web messages (#8487)
* feat: 支持 Web 排队消息携带附件

* refactor: 复用上传文件的沙箱准备流程

* fix: 修复排队附件重试、命名和暂存清理

* fix: 清理取消后遗留的排队附件

* fix: 回收已发布暂存并回滚远端排队上传

* fix: 恢复未发布的排队附件并修正代理限制
2026-11-26 22:31:55 +08:00
Loveca
3d157954e0
fix(sandbox): bound network policy event history and fail closed on database errors (#8670)
* fix(sandbox): bound network policy event history and fail closed on database errors

The restricted-mode sidecar records every denied destination in a SQLite
database on its only writable space, a 16 MiB tmpfs, and the events table
never deletes rows. A sandbox requesting many unique hosts fills the tmpfs
in minutes; after that record_denial raises, the exception escapes
handle_proxy, and denied connections get a bare TCP reset instead of 403
while the approval CLI fails against the same full database.

Prune inside the existing recording transaction, after the dedup lookup
and before the insert: drop superseded rows first, keep the newest 4000
decided rows, then drop the oldest never-surfaced undecided rows only if
still over the limit. A surfaced undecided card the user is viewing is
never dropped. Both database touch points in handle_proxy now catch
sqlite3.Error and still return 403 with the policy message.

Fixes #8669

* fix(sandbox): truncate the persisted denial method so the row cap bounds bytes

The request line has no token-length limit of its own, so a method can be
nearly MAX_HEADER_BYTES long. Stored verbatim, a few hundred oversized-method
denials fill the 16 MiB tmpfs long before MAX_EVENTS is reached. Truncate the
persisted method to 16 characters (the longest standard method is CONNECT, 7);
the denial response is unchanged. Adds an oversized-method regression through
the proxy request path asserting the stored prefix and a bounded database file.

* fix(sandbox): retain decisions by application time and reserve room for pending approvals

Review findings on the pruning semantics:

- Resolved history was ordered by the denial timestamp, so an old card
  answered after newer cards lost its just-applied decision on the next
  prune and a resumed run's replay failed. Add a decided_at column (with
  an ALTER TABLE migration for existing databases), stamp it wherever a
  decision is applied, and order retention by COALESCE(decided_at,
  created_at).
- Once resolved history filled the cap, each insert evicted an unsurfaced
  denial, reversing the oldest-first order pending_events surfaces in.
  Pending approvals now reserve capacity: history trims itself to the room
  they leave, keeping at least the most recent decision; unsurfaced rows
  are dropped only when they alone exceed the cap with no history left.
- A transient policy-lookup failure fell through to record_denial, which
  could create an approval card for a destination already holding a
  sandbox-lifetime grant; answering it with Allow temporarily would
  replace that grant with an expiring one. Lookup errors now fail closed
  without recording.

Adds regressions for the answered-old-card replay, the full-history
pending pair, the pre-decided_at migration, and the lookup failure.

* fix(sandbox): trim unsurfaced denials after retaining decisions

---------

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2026-11-26 22:30:14 +08:00
ZephyrWang
f8cde989d9
fix(skills): reject damaged archive members as invalid packages (#8685) 2026-11-26 21:16:46 +08:00
Totoro
08694c6378
fix(agents): respect custom lead reasoning in web chat modes (#8690)
Distinguish reasoning defaults supplied by the chat mode from explicit selections. Keep the configured lead reasoning and Ultra delegation independent while honoring a per-request override.

Co-authored-by: Totoro-qaq <279883115+Totoro-qaq@users.noreply.github.com>
2026-11-26 21:14:00 +08:00
ZephyrWang
9a1e1c4398
fix(input-polish): preserve Unicode separators in fenced drafts (#8644)
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
Co-authored-by: AochenShen99 <sac1063467113@hotmail.com>
2026-11-26 16:05:09 +08:00
Hyeonsang Cho
d3aad45fc6
fix(skills): reject an archive whose SKILL.md is a directory (#8648)
A SKILL.md directory in a skill archive raised IsADirectoryError in
frontmatter validation. The install routes reported it as a 500 that
echoed the host extraction temp path. Validation now returns
"SKILL.md must be a file", so install raises ValueError and both
routes return 400.

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2026-11-26 15:43:11 +08:00
Loveca
53a03624d5
fix(sandbox): screen embedded IPv4 destinations in the egress proxy address check (#8617)
* fix(sandbox): screen embedded IPv4 destinations in the egress proxy address check

The allowlist proxy judged DNS answers by is_global alone, so NAT64
(64:ff9b::/96), IPv4-compatible, and IPv4-translated (::ffff:0:0:0/96)
spellings of loopback, private, or cloud-metadata addresses passed
resolve_public. Unwrap the embedded IPv4 and apply the same check,
mirroring url_safety's unwrapping plus the translated prefix, while
keeping NAT64 spellings of public targets reachable.

Fixes #8616

* test(sandbox): follow interpreter classification for public 6to4 assertion

CPython marks 2002::/16 private only from 3.12.4 (gh-113171); the proxy
uses the interpreter's outer classification when the embedded IPv4 is
public, so pin the expectation to is_global instead of a fixed rejection.

* fix(sandbox): reject the RFC 8215 local-use NAT64 prefix explicitly

CPython classifies 64:ff9b:1::/48 as non-global only from 3.12.4
(gh-113171), and the sidecar image can pin an older interpreter, so
restricted egress must not depend on the interpreter's classification
for this range. A test simulates the pre-3.12.4 flags to pin the
explicit rejection.

---------

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2026-11-26 13:58:36 +08:00
杰尼龟
c29e1b7004
fix(sharing): preserve artifact link queries and fragments (#8626)
* fix(sharing): preserve artifact link queries and fragments

* fix(readability): preserve links in fallback without source URL

* fix(readability): distinguish document wrappers from SVG titles

* fix(sharing): preserve copied inline image URL suffixes

* fix(sharing): isolate link queries and parse fallback bodies

---------

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2026-11-26 13:54:46 +08:00
Feng Yanxin
8436b9b015
fix(browserless): redact query token from error responses and logs (#8591)
* fix(browserless): redact query token from error responses and logs

* fix(browserless): validate/redact response status headers and tighten truncation test
2026-11-26 09:17:59 +08:00
chaodidiao
b63dd7a794
fix(sandbox): report retryable capacity errors from tools (#8608)
* fix(sandbox): report retryable capacity errors from tools

* fix(sandbox): distinguish capacity service failures

* test(logging): isolate urllib3 emitter log levels

* test(coordination): use SQLite WAL for worker recovery

---------

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2026-11-26 08:50:18 +08:00
Loveca
75b6f6ae65
fix(subagents): authorize local file acceptance checks before metadata probes (#8595)
* fix(subagents): authorize local file acceptance checks before metadata probes

The local sandbox gate covered only JSON and CSV criteria, so file_exists, file_non_empty and file_written still resolved paths and probed metadata for callers without sandbox:execute. Run the same admission check for every local file family before path resolution, returning an UNVERIFIED leaf on denial.

Refs #8594

* fix(subagents): reclassify sandbox after a lazy local initialization

The provider-error branch reused the sandbox kind captured before the size probe. That probe can lazily acquire the parent's local sandbox, so a genuine Error:-prefixed report was rejected as a provider failure. Recheck is_local_sandbox after the read and cover the lazy-initialization path.

Refs #8594

* fix(subagents): decide file acceptance admission on the owning event loop

The worker-thread gate reconstructed the authorization provider synchronously. Providers that create loop-affine clients in __init__ fail that construction off-loop, so under fail_closed an authorized batch's missing-file and above-cap verdicts degraded to UNVERIFIED. The task and batch entry points now decide sandbox:execute on the event loop and carry the decision (plus the authorization-scope marker) into the offloaded checklist; the synchronous path keeps its live per-leaf gate.

Refs #8594
2026-11-26 08:11:22 +08:00
Lee minjing
3efa7804b4
perf(subagents): bulk-update items when cancelling a batch (#8623)
Co-authored-by: Leeminjing <247553113+Leeminjing@users.noreply.github.com>
2026-11-26 07:55:23 +08:00
Bas Cancrinus
80cbad0584
feat(sandbox): opt-in OpenSandbox hard cap (overflow_policy: reject) (#8639)
* feat(sandbox): add opt-in OpenSandbox capacity rejection

* fix(sandbox): count reclaimed OpenSandbox slots and warn on burst

- Keep a reclaimed warm sandbox reserved until it is registered as active,
  so a concurrent create cannot exceed the reject cap while the reclaimed
  sandbox's skill view is prepared.
- Release a create reservation under the same lock as the registration, so a
  registered sandbox is never counted twice.
- Give the capacity error the 30 second retry hint E2B uses.
- Log a warning when overflow_policy is burst: OpenSandbox keeps the soft cap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Bas Cancrinus <7222814+bascan@users.noreply.github.com>

* fix(sandbox): keep OpenSandbox slots counted until deletion is confirmed

Review of #8639 (WillemJiang), reproduced with the offline SDK fixture:
- The idle reaper and a failed health check now mark the remotes they
  remove as retiring under the same lock, and the reject cap counts them
  until their deletion succeeds (new mixin hook, a no-op for the other
  providers).
- A failed eviction keeps the slot occupied and returns a retryable
  capacity error instead of creating a replacement. An unconfirmed remote
  stays counted until its server-side lifetime ends, or until the Gateway
  restarts when sandbox_timeout is 0.
- A failed reclaim hands its reservation back to the warm pool under the
  same lock that restores the warm entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Bas Cancrinus <7222814+bascan@users.noreply.github.com>

---------

Signed-off-by: Bas Cancrinus <7222814+bascan@users.noreply.github.com>
Co-authored-by: Yufeng He <40085740+he-yufeng@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 07:54:02 +08:00
Jimmy
5c93f6d0be
fix(sandbox): ignore late terminal failure from replaced BoxLite box (#8621)
* fix(sandbox): ignore late terminal failure from replaced BoxLite box

* fix(sandbox): bind each BoxLite failure callback to its box

---------

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2026-11-26 07:52:57 +08:00
wangshun
bc69757793
fix: fix(agents): pair a malformed-id tool result even when an invalid sibling shares its name (#7822)
* fix: fix(agents): pair a malformed-id tool result even when an invalid s

Signed-off-by: wangshun <96341168+xixi-box@users.noreply.github.com>

* fix: claim results in two tiers so an invalid sibling neither blocks nor steals them

Addresses both review threads.

The blanket executable-only exclusion from the previous commit fixed #7821 but
regressed #2894: an invalid call whose real ToolMessage is already in history
lost that result to the orphan pass and got the recovery placeholder instead.
Claiming is now two-tier — executable entries first, then invalid ones as a
fallback — so an invalid sibling can neither make the only executable call look
ambiguous nor take a result an executable call can claim, while a real result for
an invalid call still survives.

Adds the regression test the backend TDD convention requires: one turn with an
executable malformed-id call and a same-name invalid sibling plus one real
result. Against the base middleware (12c304f) it fails with exactly the reported
symptom — '1 orphan(s) dropped, 2 placeholder(s) injected' and the real output
replaced by the interrupted placeholder; with this change the output stays on the
executable call and the sibling keeps its argument-error placeholder.

backend/tests/test_dangling_tool_call_middleware.py: 65 passed.

* fix: keep positional pairing on when an invalid sibling owns its own result

_turn_malformed_result_count counts every malformed result in the turn, including
one only an invalid call can claim, so comparing it against the executable-call
count alone marked a fully-accounted turn as incomplete. positional then went
False, every executable-tier match looked ambiguous, and _claim_synthetic_id
returned None for all of them: three real results dropped as orphans and
replaced with error placeholders.

Back to len(assigned), which is the same population the result count measures,
and a regression test for the compound shape (two identical executable calls +
one invalid sibling + three real results).

Signed-off-by: wangshun <96341168+xixi-box@users.noreply.github.com>

* docs(agents): align the relabel docstring with two-tier claiming

Signed-off-by: wangshun <96341168+xixi-box@users.noreply.github.com>

* fix(agents): prioritize exact tool result names

---------

Signed-off-by: wangshun <96341168+xixi-box@users.noreply.github.com>
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2026-11-26 07:46:59 +08:00
杰尼龟
aa9913c4cc
fix(scheduler-ui): preserve seconds in local one-time timestamps (#8627)
* fix(scheduler-ui): preserve seconds in local one-time timestamps

* fix(readability): preserve links in fallback without source URL

* fix(readability): distinguish document wrappers from SVG titles

* fix(scheduler-ui): accept fractional timestamps without seconds
2026-11-25 23:24:51 +08:00
Hyeonsang Cho
f3dfb55110
fix(skills): write each history record whole under the history file lock (#8557)
* fix(skills): append each history record in one O_APPEND write

append_history wrote the JSON record and its LF terminator as two writes
through a text file. A record holding two SKILL.md revisions outgrows the
file buffer, so the record went out directly and the terminator
separately. Appenders that do not share a lock, such as the skill_manage
tool and the skill routes, or two Gateway workers, could land another
record in between. read_history then rejected the joined line, and the
skill's history and rollback routes failed from then on.

Encode the record with its terminator first and write it with one
O_APPEND os.write, continuing after a short write.

* fix(skills): hold the history file lock across a record's retries

O_APPEND makes one write atomic, but finishing a short write takes a
second one, and another writer's record could land between the two.
append_history now holds an exclusive lock on the history file while it
writes the whole record. The operation mirror, the other writer of the
same file, takes the same lock around its read, check and append, so its
records cannot land inside one either.

The lock belongs to the open file, so it serializes threads of one
process as well as processes, and it is always the innermost lock.

* test(skills): skip the operation mirror lock test off POSIX

mirror_operations opens the history directory through POSIX directory
descriptors and open flags that CPython does not expose on Windows. Skip
that case there, as the host mutation suite does, so the portable
history append tests still run.

* fix(skills): read history under the history file's shared lock

read_history read the file without the lock, so a read that landed while
a short write was being retried saw half a record and raised
JSONDecodeError. Readers now hold the lock in shared mode (exclusive on
Windows, where msvcrt.locking has no shared mode).

The guide and the append comment now state the real guarantee: each
record is appended whole under the history file's lock, which can take
more than one write.

* test(skills): wait at the history lock instead of a timed join

The short-write interleaving tests let the other reader, appender or
mirror run for up to 0.5 s and then retried. A lock-free path that was
scheduled after the retry passed them. The holder of the short write now
retries only once the other thread is at the history lock, or has
finished without it; the mirror test waits until the append is blocked
on the mirror's lock or has made its short write.

* test(skills): release the retry once the other thread is blocked on the lock

Waiting only for the other thread's lock attempt let it race the retry
when the retry ran outside the lock, so that variant failed one storage
and passed the other. The retry now waits until the other thread is
blocked on the lock, or has finished without waiting for it. All three
interleaving tests use the same barrier.

* chore(skills): mark the Windows fcntl fallback type: ignore

Match the other fcntl fallbacks, including deerflow/skills/projection.py
and the custom-skill mutation lock.
2026-11-25 23:24:35 +08:00
Bas Cancrinus
526864b47e
feat(mcp): maintain agent credential grants at runtime (grants: runtime) (#8512)
* feat(mcp): maintain agent credential grants at runtime (grants: runtime)

An mcp_agent_auth binding can declare grants: runtime. config.yaml then keeps
only the server, agent and OAuth client; an administrator maintains the owners
and approved definition digests through /api/mcp/agent-auth, stored with the
agent_storage backend (table mcp_agent_grants, migration 0059, or one JSON file
per binding). A runtime binding without a grant admits nobody.

Run admission reads the grant for each matching binding, and every protected
call rechecks the owners, so a change applies without a Gateway restart:
removing an owner denies the next call, removing a digest stops new runs while
admitted runs keep their definition. An unreadable grant store denies admission
and calls. The API refuses writes to grants: config bindings and owners that
another enabled binding already covers for the same server and agent; admission
also fails closed if overlapping runtime grants race past that check.

grants: config (the default) behaves as before.

Closes #8503

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Bas Cancrinus <7222814+bascan@users.noreply.github.com>

* fix(mcp): bind a runtime grant to the identity it was approved for

A runtime grant was keyed by binding ID only, so its owners and digests stayed
in force after config.yaml pointed the binding at another agent, server or
OAuth client, or the server at another destination. Each grant now records
that subject (agent, server, destination digest, nonsecret credential digest)
when an administrator writes it; admission and every protected call apply the
grant only while the subject still matches. Rotating the client secret keeps
it. The admin API reports approval: current/stale/none/config, and the overlap
check ignores grants that are no longer in force.

Also renumbers the migration to 0060 after upstream's 0059_coordination_grants.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Bas Cancrinus <7222814+bascan@users.noreply.github.com>

* fix(mcp): build grant stores off the event loop; reject owners file storage cannot hold

The admin routes built the grant store on the event loop; with SQLite the
factory resolves the database path on the filesystem. Construct the store in
the worker thread together with the read or drained write.

definition-digest with file-backed agent storage turned an owner such as
"alice@example.com" or "../alice" into a 500 from Paths.user_dir; it now
answers 422. Database-backed owners stay unrestricted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Bas Cancrinus <7222814+bascan@users.noreply.github.com>

* test(mcp): put 0061_mcp_agent_grants after 0060_coordination_run_settings in the chain test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Bas Cancrinus <7222814+bascan@users.noreply.github.com>

* fix(mcp): keep stale and retired runtime grants reserved, let admins delete them

- The owner overlap check counts every stored grant for the agent and server
  it was approved for, also while it is stale or its binding is gone, so a
  configuration rollback cannot reactivate a grant whose owners another
  binding took in the meantime.
- A grant whose binding was removed from config.yaml is listed and readable
  as approval: retired and can be deleted by its binding ID, which releases
  its owners. A grant left behind on a binding moved to grants: config can be
  deleted too.
- The file store treats a grant file removed by a concurrent delete as absent
  in get, list, put and delete; parse and other I/O errors still raise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Bas Cancrinus <7222814+bascan@users.noreply.github.com>

* fix(mcp): chain grants after 0061_coordination_coordinator; keep owners of disabled bindings reserved

Rename the grants migration to 0062_mcp_agent_grants with down_revision
0061_coordination_coordinator so main keeps a single Alembic head, and
check the whole upgrade path in the chain test.

A disabled binding now keeps its owners reserved (stored grants and
grants: config owners), and a grant written to a disabled binding is
checked for overlaps too, so enabling it again cannot make admission
reject both bindings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Bas Cancrinus <7222814+bascan@users.noreply.github.com>

* fix(mcp): show a stored runtime grant on a binding moved to config grants

A grants: config binding whose earlier runtime grant is still stored hid that
grant in both GET routes, while the overlap check still counted its owners:
an administrator could get a 409 for an owner absent from the binding's
details. Both routes now return it as stored_grant (server, agent, owners,
digests) until it is deleted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Bas Cancrinus <7222814+bascan@users.noreply.github.com>

---------

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>
2026-11-25 23:23:47 +08:00
哈基米
5f964ba2f0
fix(projects): keep shelf index entries line-atomic (#8521)
* fix(projects): keep shelf index entries line-atomic

* fix(projects): keep the project name on one line in the rendered block

Follow-up from the review of the shelf index fix: the project name is
member-settable untrusted text rendered into the `<project>` open tag.
The attribute escaper leaves line boundaries intact, so a name containing
one pushed attacker-chosen lines into the rendered framework block.

Reuse `_one_line` for the name, as the shelf entries already do. The new
test covers every line boundary `str.splitlines` recognizes and fails on
the previous code.

* test(projects): cover every splitlines boundary in the name fold test

The parametrization omitted \x1c, \x1d and \x1e, three of the boundaries
str.splitlines recognizes. All eleven cases fail without the fold.

The docstring said attribute values are folded; only the name is. The
project id is a server-generated UUID and stays as it is.
2026-11-25 22:53:46 +08:00
Kevin Hsiao
882063d83d
feat(vefaas-sandbox): add speculative prewarm, snapshots, pause/resume, and image precache (#8513)
* feat(vefaas-sandbox): add snapshots, pause/resume, and image precache

Implement Phase 2 of #8426 on top of #8449:
- Extend VeFaaSClient (OpenAPI Version=2024-06-06) with PauseSandbox,
  ResumeSandbox, CreateSandboxSnapshot, DescribeSandboxSnapshot,
  ListSandboxSnapshots (paginated), DeleteSandboxSnapshot,
  PrecacheSandboxImages, GetSandboxImagePrecacheTicket, plus SnapshotId
  and AutoPauseConfig support on CreateSandbox.
- Add opt-in lifecycle controls to VeFaaSSandboxProvider: pause_on_idle,
  auto_pause, snapshot_on_idle (with scoped metadata filtering and old
  snapshot pruning), base snapshot_id, precache_images, and off-loop
  precache_on_startup, plus public snapshot/precache helper methods.
- Preserve ownership lease fencing, dirty-sandbox exclusion, cross-tenant
  snapshot isolation, retryable shutdown, and non-blocking event-loop
  guarantees with offline unit and Blockbuster tests.

* fix(vefaas-sandbox): harden snapshot teardown lease, auto-pause reclaim, and manual snapshot shutdown fence

Address all review findings on #8513:
- Keep destructive teardown leases alive via a heartbeat and poll-tick
  refresh throughout idle pause/snapshot retirement, and re-verify
  claim(..., for_destroy=True) right before KillSandbox so a peer-adopted
  sandbox is never killed if the lease is lost mid-snapshot.
- Detect paused/transitioning warm instances in _reclaim_warm_pool via
  DescribeSandbox and hand them off to discovery/resume instead of
  killing them on failed HTTP readiness.
- Fence manual create_snapshot() source sandboxes via
  _snapshotting_remote_ids so concurrent shutdown() stays retryable and
  leaves the source alive until the snapshot settles.
- Move shared veFaaS offline test helpers into tests/support/vefaas_sandbox.py
  and add deterministic regression tests for all three scenarios.

* fix(vefaas-sandbox): keep paused warm sandboxes tracked during reacquire

Resume paused or transitioning warm-pool entries in place inside
_reclaim_warm_pool() instead of popping _warm_pool ahead of
ListSandboxes discovery:

- Keep the owned warm entry tracked in _warm_pool across transient 5xx
  control-plane errors (DescribeSandbox / ResumeSandbox), readiness
  timeouts, and ownership backend errors so shutdown() after recovery
  still sends KillSandbox and retry acquire() resumes without duplicates.
- Only discard a warm entry without teardown once the known remote
  instance is authoritatively confirmed absent/terminal (DescribeSandbox
  returning None/terminal or ResumeSandbox raising SandboxNotFound) or
  confirmed under a peer teardown lease.
- Move unadoptable resumed warm instances (e.g. invalid/mismatched init
  marker) atomically to _pending_destroys and tear them down via
  _destroy_tracked() rather than forgetting them.
- Handle concurrent shutdown rollback cleanly when resuming/publishing a
  paused warm entry and avoid falling through to discovery/create after
  shutdown starts.

* feat(vefaas-sandbox): support speculative sandbox prewarm

Fold speculative sandbox prewarm support for VeFaaSSandboxProvider (formerly
#8492) into #8513 so prewarm, snapshots, pause/resume, and image precache
land together on top of #8449.

* chore(vefaas-sandbox): address CodeQL quality findings

- Scope `needs_kill` inside the claimed teardown branch in `_retire_warm_entry`
  so the peer-owned branch does not write an unread local variable.
- Catch `Exception` rather than `BaseException` in the concurrent resume test
  helper thread.

* fix(vefaas-sandbox): retain teardown fence until async snapshots settle

When `create_snapshot(..., wait=False)` returns early or `wait=True` exits
without an authoritative terminal/ready state (such as `TimeoutError` or a
transient describe error), hand off the `_snapshotting_remote_ids` refcount
to a background completion watcher thread instead of releasing the fence in
`finally`. Keep warm-pool reaping/eviction, shutdown, and client teardown
fenced (while continuing ownership lease renewal) until the control plane
confirms Ready, terminal failure, or SnapshotNotFound.

* fix(benchmark): pass OpenSandbox instance to _invalidate_sandbox

Follow-up to #8507 (`6cefec0c9`), which changed
`OpenSandboxProvider._invalidate_sandbox` to accept an `OpenSandboxSandbox`
instance instead of `sandbox_id: str`. Look up the active or warm sandbox
instance under `self._lock` inside `BenchmarkOpenSandboxProvider.destroy()`
before calling `_invalidate_sandbox()`.

* fix(vefaas-sandbox): keep ownership lease renewal active during manual snapshots

Stop inserting `sandbox_id` into `_acquire_inflight` during `create_snapshot()`.
Local reaping, eviction, teardown, and shutdown are already fenced by
`_snapshotting_remote_ids`, whereas `_acquire_inflight` caused
`_renew_leases_once()` to skip renewing the ownership lease during long
synchronous `create_snapshot(..., wait=True)` waits.

* fix(vefaas-sandbox): hand off and refresh ownership leases across resume waits

- Use `take(sandbox_id)` when resuming a `Paused` sandbox so a turn landing on
  another worker can cleanly transfer a normal `own:` lease from a peer holding
  an auto-paused warm entry while still rejecting a destructive `del:` lease
  with `_PeerTeardownError`.
- Keep the normal `own:` lease refreshed throughout `ResumeSandbox`,
  `_wait_for_remote_running()`, and `wait_for_sandbox_ready()` via
  `_ownership_lease_heartbeat()` plus poll-tick `_refresh_owned_lease()`
  callbacks, and authoritatively verify ownership (`_verify_owned_lease_strict`)
  before adopting with `ownership_claimed=True`.

* fix(vefaas-sandbox): reserve cross-worker snapshot fence before manual snapshots

- Reject `create_snapshot()` on stale/peer-owned handles via `claim(sandbox_id)`
  before calling `CreateSandboxSnapshot`.
- Reserve a remote-scoped cross-worker snapshot fence
  (`snapshot-fence:<remote_id>` with `for_destroy=True`), perform a Dekker
  re-check on `claim(sandbox_id)` so teardown and snapshot admission cannot
  interleave, and keep the fence refreshed across synchronous waits
  (`_teardown_lease_heartbeat` + poll-tick refresh), async completion watchers,
  and `_renew_leases_once()` until the snapshot settles.
- Guard `_retire_warm_entry()`, `_destroy_tracked()`, and `shutdown()` against
  active cross-worker snapshot fences (unwinding any destructive `del:` lease
  and deferring teardown until the remote snapshot settles).

* fix(vefaas-sandbox): address P2 review findings on snapshot fencing, filtering, and restore

- Keep deferred warm-pool `AioSandbox` handles open in `_destroy_tracked()` and
  `_retire_warm_entry()`, closing the local handle only once teardown proceeds
  or the entry leaves `_warm_pool` (WillemJiang P2).
- Retain local and cross-worker snapshot fences after uncertain
  `CreateSandboxSnapshot` failures (timeouts, transport errors, 5xx) and
  reconcile via a background watcher polling `ListSandboxSnapshots(SandboxId=...)`
  and `DescribeSandbox` until no snapshot is in progress (WillemJiang P2).
- Serialize cross-worker `snapshot-fence:<remote_id>` last-key release with new
  reservations via a per-remote `_snapshot_fence_lock()` (Codex P2).
- Pass server-side `Filters` (`Metadata.*` and `Status`) in
  `_find_latest_ready_snapshot()`, `_prune_old_snapshots()`, and
  `list_snapshots()`, caching graceful fallback if a backend rejects filters
  while keeping strict client-side metadata verification (YukoOshima P2).
- Refresh `/mnt/skills` and host `uploads/` (without overwriting snapshot
  workspace/outputs) when booting from a snapshot that preserved
  `/tmp/.deerflow-vefaas-initialized`, and document snapshot retention/cleanup
  in `README.md` (YukoOshima questions).
2026-11-25 22:08:41 +08:00
Bas Cancrinus
f56fb962d0
fix(sandbox): defer fresh OpenSandbox skill-policy acquisition (#8590)
* fix(sandbox): defer fresh OpenSandbox skill-policy acquisition

OpenSandbox acquire now installs the thread's prepared skill view on new
and warm remotes (clearing first, so a failed upload never leaves another
view behind), and the provider opts in to
supports_lazy_agent_skill_isolation. A fresh run with an explicit Agent
skill list, including an empty one, no longer acquires a remote before
its first sandbox tool call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Bas Cancrinus <7222814+bascan@users.noreply.github.com>

* fix(sandbox): keep eager skill sync when the thread's OpenSandbox remote is active

A deferred acquire reuses an active remote after renew() without installing
the run's prepared skill view, so a policy-scoped run that starts while an
upload holds the thread's remote would keep the previous view. Providers can
now report such a remote (holds_active_thread_sandbox); the middleware then
keeps the eager acquire and strict sync_agent_skills. Fresh runs still defer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Bas Cancrinus <7222814+bascan@users.noreply.github.com>

* docs: remove changelog changes from OpenSandbox fix

* fix(opensandbox): sync skills when a remote is initializing

---------

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>
2026-11-25 21:26:16 +08:00
ZephyrWang
72ca21dd4b
fix(client): honor saved and per-call reasoning effort (#8597)
* fix(client): honor named-agent and per-call reasoning effort

* fix(client): keep reasoning graphs local to each turn
2026-11-25 21:20:48 +08:00
kongxin
6e3746e04e
fix(sandbox): stop the rest of a cancelled AIO command (#8566)
* fix(sandbox): stop the rest of a cancelled AIO command

The AIO persistent shell and the bash.exec script export the cancel marker
after bash has started, so bash's own /proc environ lacks it. Cleanup
terminated only the marked children, and bash then ran the remaining
statements of a `;`, newline, loop, pipeline or subshell command after the
run was cancelled.

Cleanup now first sends SIGINT to every process in a process group that
contains a marked process, as Ctrl-C would, and then terminates the marked
processes as before. An interactive shell drops the rest of the line and
keeps its cwd and exports; a one-off `bash -c` exits. A process group never
spans sessions, so only the shell session that ran the command is reached.

* test(sandbox): keep persistent-shell teardown quiet when the shell is gone
2026-11-25 21:14:08 +08:00
Hyeonsang Cho
7643ca0452
fix(skills): make skill_manage share the routes' custom-skill mutation lock (#8568)
* fix(skills): make skill_manage share the routes' custom-skill mutation lock

The skill routes hold a per-owner lock (a process lock plus a sidecar
flock) around read -> write -> history. skill_manage held only its own
process-local per-skill lock, so a tool edit and a route edit of the same
skill could interleave, in one Gateway process or across several. One
overwrote the other while recording a stale prev_content, and the
overwritten revision dropped out of the history chain rollback walks.

Move the lock into deerflow.skills.mutation_lock and use it from both.
The tool takes it after its scans, so a slow model scan does not queue the
owner's other mutations, and re-reads under it what the scans assumed:
- patch is refused when SKILL.md changed since the patch was derived;
- edit and write_file record the content they actually overwrite;
- write_file does not recreate a skill deleted meanwhile;
- create does not overwrite a skill created meanwhile.

* chore(skills): keep the type: ignore on the Windows fcntl fallback

The routes carried it before the lock moved, and the other fcntl
fallbacks, including deerflow/skills/projection.py, still do.
2026-11-25 20:39:36 +08:00
Houston
5d9ee09df9
fix(runtime): stop replaying ambiguous subagent event writes (#7711)
* fix(runtime): stop replaying ambiguous subagent event writes

* fix(runtime): classify safe retries and bound subagent persistence failures

* fix(runtime): quarantine deterministic batch failures instead of retrying

* fix(runtime): verify subagent batch rollback and producer completion

Classify transient failures before database commit using driver codes. Restore JSONL appends in reverse order and propagate rollback uncertainty. Keep the SQL producer open when subagent persistence stops without confirmation.

---------

Co-authored-by: Houston <347629597+HoustonJia@users.noreply.github.com>
Co-authored-by: Nan Gao <thunderggnn@gmail.com>
2026-11-25 19:06:15 +08:00
ZephyrWang
2629c0bb78
fix(acp): select the configured model before prompting (#8600)
* fix(acp): select the configured model before prompting

* fix(acp): verify configured session model selection
2026-11-25 16:59:06 +08:00
Yufeng He
126ad9dc37
fix(agents): keep an unrenderable summary_prompt from failing the run (#7667)
* fix(agents): keep an unrenderable summary_prompt from failing the run

summary_prompt is a str.format template with a {messages} slot, so a
literal brace has to be doubled. The render runs outside the try that
guards the model call, so an unescaped brace raised KeyError out of
abefore_model and failed the turn instead of skipping compaction.

The middleware already documents the opposite: the automatic path
swallows a summary failure and leaves compaction state unchanged, and
raise_on_failure reports a real failure as SummaryGenerationError so
/compact can tell it from "nothing to compact". Route the render through
_render_summary_prompt, which turns a failure into None with a warning
naming the brace rule, and let the existing None path apply.

docs/summarization.md now states the template syntax.

* fix(agents): cover attribute and index template failures in summary_prompt rendering

Expand the render exception tuple to include AttributeError and TypeError so
{messages.foo} and {messages[missing]} share the same fail-open boundary as
literal braces and unknown placeholders. Add summary_prompt_hash to the
warning so operators can correlate the log line with the offending config
without the template or history appearing in logs.

Rewrite the regression suite around a real create_agent graph with
InMemorySaver: template failures preserve history and the checkpoint, the
summary model is never reached, and a repaired template recovers on the next
attempt. Document the template syntax and failure contract in
summarization.md, the middleware AGENTS.md, and the root README.

* fix(agents): log summary template error types only

---------

Signed-off-by: Yufeng He <40085740+he-yufeng@users.noreply.github.com>
2026-11-25 11:41:04 +08:00
Wenchao An
adba516884
feat(coordination): add atomic coordinator task dispatch (#8558)
* feat(coordination): add atomic coordinator task dispatch

* fix(coordination): settle the current plan and forward visible replies

* fix(coordination): retry transient planner failures once

* fix(coordination): preserve planner privacy and replay inputs
2026-11-25 10:18:53 +08:00
Totoro
b2061d8488
fix(runtime): complete runs at a terminal step-limit checkpoint (#8593)
Co-authored-by: Totoro-qaq <279883115+Totoro-qaq@users.noreply.github.com>
2026-11-25 10:15:10 +08:00
zzj84862-creator
4223e0710c
fix(skills): reclaim idle projection lock entries (#8564)
Co-authored-by: zzj84862-creator <252897181+zzj84862-creator@users.noreply.github.com>
2026-11-24 23:31:10 +08:00
ChengLong GU
6f5e24b500
fix(sandbox): forward operator environment to provisioned pods (#8370)
* fix(sandbox): forward operator environment to provisioned pods

* docs(sandbox): record the Kubernetes idle baseline

* test(sandbox): fold operator environment cases into the provisioner suite

* fix(provisioner): keep the operator environment budget and values intact

Generated capacity settings no longer travel in the forwarded map, so all 32
entries belong to the operator. Pod values are escaped before they reach the
API server, and a key with a trailing newline is rejected at validation.

* fix(provisioner): fail an unusable environment map when the backend is built

The provisioner rejects a forwarded map it cannot apply, which used to surface
only as a bare 422 on the first sandbox create. The backend now applies the same
limits while it is constructed and names the setting and key that offend, so the
failure lands before any Pod is attempted.
The provisioner README and the memory guide also record that the profile needs
the newer provisioner, and that existing Pods keep their environment.

* fix(provisioner): reject an unusable environment map at Gateway start-up

* fix(provisioner): tighten the start-up refusal wording

* fix(provisioner): skip the start-up check when the map is empty

---------

Co-authored-by: gcl-coder <gcl-coder@users.noreply.github.com>
2026-11-24 21:14:34 +08:00
Bas Cancrinus
b5e19e03a0
feat(crawl4ai): configurable web_fetch output cap and a truncation note (#8553)
* feat(crawl4ai): configurable web_fetch output cap and a truncation note

Crawl4AI web_fetch cut pages to a hard-coded 4096 characters without saying so.
An optional max_chars tool setting (positive integer, default 4096) sets the
cap; invalid values keep the default with a warning. A cut page ends with
'[web_fetch: truncated to the first N of M characters]'.

Refs #8552

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(changelog): crawl4ai web_fetch max_chars

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(crawl4ai): fall back when max_chars cannot be parsed

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2026-11-24 21:13:14 +08:00
ZephyrWang
efc98f1164
fix(mcp): expose structured-only stdio tool results (#8542)
* fix(mcp): expose structured-only stdio tool results

Use a JSON text fallback when a successful stdio MCP result contains
structuredContent without content blocks. Retain the structured artifact
and existing text, media and error handling.

Extend the existing discovery/pooling/graph regression with populated
and empty JSON objects.

Fixes #8541

* fix(mcp): translate file paths in structured stdio results

---------

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2026-11-24 20:49:31 +08:00
Yusen Meng
178edb4721
feat(memory): support multi-user and multi-tenant isolation in openviking (#8441)
* docs(openviking): document multi-user and multi-tenant isolation

* feat(memory): support multi-user and multi-tenant isolation in openviking (#8420)

* fix(memory): fall back to viking://~/ URIs on OpenViking >=0.5.5

* fix(memory): address OpenViking multi-user PR review findings

* fix(memory): reject single-user client_pool and scope static tenant errors

* fix(memory): normalize provider MemoryManagerError to honor read failure policy

* fix(memory): allow admitted OpenViking operations to acquire clients during shutdown drain

* fix(memory): bound OpenViking provider cleanup on shutdown and harden diagnostics

* fix(memory): avoid waiting on cleanup from _end_operation tail

* fix(memory): run recorder and provider cleanup in single shutdown worker

* fix(memory): harden multi-user api_key_env validation and cleanup worker start failure
2026-11-24 16:01:11 +08:00
zzj84862-creator
b8e03f71de
fix(sandbox): offload unexpected sandbox-init error sanitization off event loop (#8537)
* fix(sandbox): offload unexpected sandbox-init error sanitization off event loop

* test(sandbox): bound cancellation test startup wait and cleanup

---------

Co-authored-by: zzj84862-creator <252897181+zzj84862-creator@users.noreply.github.com>
2026-11-24 15:45:45 +08:00