* 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>
* 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>
* 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>
A trailing ".skill/" requests no archive member at all. The empty internal
path fell through to the archive lookup's fallback match, which matched the
first directory entry (name ends with "/") and returned its empty body with
200 instead of 404.
Reject an empty internal path in the skill branch before extraction. The
regression test ships an archive with the usual explicit directory entry and
asserts the trailing-slash request answers 404.
* 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.
* 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>
* 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.
* 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).
* feat(sandbox): configure AIO sandbox Pod resource requests and limits
* fix(helm): reject unknown sandbox resource keys
Validate sandboxResources requests and limits against the three resource names the AIO provisioner reads. Helm now reports misspellings and unsupported extended resources during rendering, before a sandbox can start with the default limit.
Cover a misspelled memory limit and an extended resource request in the Helm render tests.
* 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>
* 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
* 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.
* 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>
* fix(hitl): warn loudly when hitl_approval is disabled instead of silently skipping the middleware
Raised in #8431: _insert_hitl_approval_middleware returns silently when
hitl_approval is absent or enabled != true, so agents run tools without
runtime human approval and nothing in the logs marks it. This keeps the
default (no behavior change) but makes the fail-open posture visible:
- emit a warning at middleware insertion time, with the exact config
keys to flip and a doc pointer
- state the disabled-by-default posture explicitly in docs/guide
Signed-off-by: DSHCorrectover <correctover@sina.com>
* test(hitl): unit tests for the disabled-visibility warning (three mount states)
- absence of hitl_approval -> warning + no middleware
- enabled=false -> warning + no middleware
- enabled=true -> middleware mounted, no warning
Runs the same assertions as our internal replay (AST guard-uniqueness,
mount-point coverage, behavioral stub replay) against the real package;
maintainer CI is the authoritative run.
Signed-off-by: DSHCorrectover <correctover@sina.com>
* fix(hitl): report disabled approvals at Gateway startup
---------
Signed-off-by: DSHCorrectover <correctover@sina.com>
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
* fix(nginx): leave multipart headroom above the upload limit
Gateway's default 100 MiB upload ceiling counts file bytes only, while nginx's 100M limit also has to carry multipart headers and boundaries. Two valid 50 MiB files therefore exceed nginx and return 413 before Gateway can apply its limits. Raise the thread-upload and project-document locations to 101M in the Docker, local-dev and Helm configs, and assert the proxy limit is strictly greater than Gateway's total content limit.
* test(nginx): size upload headroom from multipart framing
Compare the proxy ceiling with a representative multipart body: Gateway's maximum content plus part headers, closing boundary and filename slack. Base project-document headroom on its single-file limit. Document that uploads.* is runtime-configurable while the nginx ceilings are static, and drop the hardcoded 101M from unrelated prose.
---------
Co-authored-by: Tong-bit-art <Tong-bit-art@users.noreply.github.com>
* fix(feishu): keep links and code blocks from rich-text posts
A Feishu message with a hyperlink or a code block arrives as a post. The
parser kept only text/at elements and attachment placeholders, so `a` and
`code_block` elements were dropped and the agent got the question without
the link or the code.
Render a link as [text](url), or the bare URL when the text is the URL, and
a code block as a fenced block tagged with its language, using a fence
longer than any backtick run in the code.
* fix(feishu): start a post code block on its own line and escape link labels
A code block that shares a paragraph with text was space-joined into one
line, where its opening fence does not start a block. Emit it as its own
paragraph instead.
Escape brackets and backslashes in a link label so a "]" cannot end the
link text early, and put a URL with parentheses or spaces in <...>.
---------
Co-authored-by: HYYAlex <232531662+HYYAlex@users.noreply.github.com>
* 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>
* 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>
* 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>
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(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>