Subagent/coding tools agent integration c77be280 - #1
Open
fffonion wants to merge 44 commits into
Open
Conversation
Replace the blocked provider.call/tool.dispatch skeleton with a real serial loop in rss/agent/main.rss. The loop builds canonical LlmRequest maps and invokes the selected provider adapter through a bounded native RSS host bridge in rss_runner; tool calls dispatch serially via the Task5 DispatchContext without resetting its cumulative budget. Follow-up assistant tool_call parts use lossless arguments_json strings, and tool results stay user-role tool_result parts so OpenAI Chat and other adapters consume one contract. Provider/network errors consume the existing retry/backoff budget; completed tool effects are never retried. Parallel and task dispatch stay typed unsupported. Tests drive a scripted provider plus the native dispatch bridge covering text-only, serial tools, retry, budgets, cancel/deadline, and malformed responses, and convert a real loop follow-up through the OpenAI Chat request builder.
Release-parallel dispatch tests raced reopen against a previous exclusive holder whose Drop still ran on another thread. Retry the non-blocking flock briefly so a dead store can release before the open fails closed; a live second writer still gets artifact_store_busy.
Share ToolResult serialized caps, ToolOwner validation, workspace/output ceilings, and caller cancellation/deadline across file, terminal, and process tools. ArtifactStore implements ProcessArtifactSink with owner-scoped cleanup.
Pin pd-vm to f9ca414 and replace terminal path check-use cwd with a retained ConfinedFsRoot, open_directory, and with_confined_cwd.
Serial native dispatch validates names and JSON Schema against the admitted registry snapshot before any effect. Lifecycle events are committed in requested/started/output/completed-or-failed order, with no publication after terminal ownership or a failed durable append. Terminal and process calls use a linked per-call cancellation token so core process Drop cannot cancel the run; a bounded RAII watcher relays run/stop cancellation and joins before returning. File calls use the run token directly.
Pool owner-scoped ArtifactStore by identity-safe root so concurrent runs in one workspace share one store while different roots stay isolated. Close and quiesce the run serial gate before owner cleanup so in-flight puts cannot commit after drop. Derive executor and envelope caps from admitted RunLimits.max_tool_output_bytes, keep stdout+stderr in overflow artifacts, and initialize native dispatch in two phases without holding the handle lock across filesystem IO.
Commit canonical durable tool-call/result schema, step transactions before live publish, idempotent replay, interrupted-effect recovery, and atomic final assistant + run.completed.
Reserve seq/ordinal without partial-moving RSS maps, attach tool results only after a live handle and assistant parent exist, and refuse pending-provider retry on worker terminals while still recovering gateway_restart runs.
Include optional RunContext.coding_system_prompt in the VM map and prepend it once onto local loop LlmRequest messages without mutating durable rows or leaking into loop events.
Wire run_worker to AgentRunner with production/scripted provider hosts and the run-scoped native dispatcher. Keep RunHandle.cancellation as the sole root, pass remaining admission deadline without reset, restore expired wall-clock deadlines as typed cancel, and wait for process-owner cleanup before the terminal commit.
Wire replay-safe coding-activity counters at the provider-host call and durable dispatch seams. Model calls count each actual host attempt, including retryable failures; turns count only successfully normalized responses; tool counters follow the dispatcher's new-vs-replay decision.
Bound uncooperative host cleanup and fail closed when teardown does not quiesce. Restore Stopping runs by requesting cancel before the next provider call, reject huge persisted deadlines as typed errors, treat injected providers as one-shot, and interrupt retry backoff on stop. Runner prepare/drive faults disarm the epoch watcher; process teardown reports a cleanup outcome instead of waiting unbounded.
Port both coding E2E suites off lease temp paths, clear inherited git fixture env, and drive terminal argv through a located POSIX sh helper. Tighten durable chain, stop lifecycle, and overflow assertions to exact parent/name/ordinal/truncation contracts, and document both local E2E commands. Mark completed-run reopen as a no-op until pending-turn replay lands on final integration.
Drive coding E2E through production DurableProviderHost with plain ScriptedProvider injection. Replace helper masking with pending-request retry, completed-step replay, and unsafe pending fail-closed coverage, and document the exact durable replay contract including the external exactly-once receiver limitation.
Pass attempt into Task10 unsafe-pending E2E and re-inject the one-shot provider before crash-after-request redrive so Phase B recovery tests match integration worker semantics.
The resume-gate test timed out waiting for [done] because the follow-up run fail-closed with artifact_store_busy. Catch-up already rendered gateway_restart and released the session gate; the parked phase-1 worker still held the exclusive flock on the cwd-derived artifact store. Give each telegram test gateway its own workspace so in-process restart matches two-process crash semantics, and assert the follow-up run is not a second [failed] / artifact_store_busy.
Export canonical RSS descriptors, enablement, validation, and deterministic identity input for the six current tools without switching production dispatch.
Persist canonical ToolResult through DurableEventCommitter::commit_step for production commit_result and interrupt, retain ExecutionLease from prepare until commit, recover open tokens on stop/shutdown/drop, reject same-run retry of unresolved calls, and add authorize() for future cap::* effects.
Keep eager close before durable result I/O, but associate call IDs with every TokenState so same-call prepare cannot re-issue a token after a failed durable commit or interrupt. Validate canonical tool results before closing so invalid payloads return InvalidMetadata and remain Open for a corrected commit.
Add generic filesystem, process, and artifact primitives that require a valid Task 0B execution token before every effect. Register them as cap::* host functions without embedding RSS tool names or schemas.
Drive process cancel-all from run state so spawned children die on cancel, recover, stop, shutdown, and drop. Freeze ConfinedFsRoot at admission, bound listing to admitted page/cursor, serialize write_atomic CAS, clamp process ceilings from host config, and return lossless Value::Bytes for fs/artifact payloads.
Fail closed on signed/overflow/wrong-type host args, zero pagination limits, and unsupported readdir errno instead of coercing them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.