refactor!: extract shared agent system engine - #96
Open
shadaj wants to merge 1 commit into
Open
Conversation
Deploying infinity with
|
| Latest commit: |
db1d501
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://6502eb17.infinity-dc7.pages.dev |
| Branch Preview URL: | https://sandbox-0f86f15a-4591-435a-b.infinity-dc7.pages.dev |
shadaj
force-pushed
the
sandbox-0f86f15a-4591-435a-bff7-27a45f33e143
branch
from
August 13, 2026 02:58
1db2de7 to
cf0a764
Compare
shadaj
marked this pull request as ready for review
August 13, 2026 02:58
shadaj
force-pushed
the
sandbox-0f86f15a-4591-435a-bff7-27a45f33e143
branch
from
August 13, 2026 03:02
cf0a764 to
c518863
Compare
Move the daemon and Lambda runtimes onto the shared infinity-agent-core engine, including routing, lifecycle, state-store, observer, step-processing, and shutdown behavior. Split MCP and RAP integrations into reusable bridge crates and retain migrated daemon fidelity coverage. Keep application-facing local tool-set adapters, static builder conveniences, and usage guides in the stacked high-level API change. BREAKING CHANGE: removes the legacy batch processor API in favor of the step-oriented API. Co-authored-by: Infinity 🤖 <infinity@hydro.run> PR: #96
shadaj
force-pushed
the
sandbox-0f86f15a-4591-435a-bff7-27a45f33e143
branch
from
August 13, 2026 22:13
c518863 to
db1d501
Compare
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.
Stack
This is PR 1 of 2. Review and merge this PR first. The additive high-level API is split into #92, which is based on this branch.
Summary
Extract the daemon's agent execution machinery into a shared
infinity_agent_core::systemengine, migrate the daemon and Lambda runtimes onto it, and extract the protocol components those embeddings share.This PR intentionally stops at the engine and embedding boundary. Static builder conveniences, local MCP/RAP tool-set adapters,
ThreadHandle, launcher mode, per-thread launch configuration, and the new usage guides are introduced by #92.Review guide
Most of this diff is relocation. The old daemon
thread_worker.rsandagent_loop.rsloops, plus the old core batch processor, are replaced by focused core modules. The migrated daemon tests insystem/tests.rsand their unchanged snapshots are the fidelity evidence for the port.Shared engine
system/local/driver.rsports the worker loop: batching, cancellation, deferral, compaction, tool-result waiting, and idle exit.system/thread.rsowns the completion pipeline, commit ordering, observer calls, config resolution, and tool dispatch.system/local/router.rsowns input routing, driver spawning, wake admission, subscriptions, lifecycle notifications, and shutdown.system/builder.rsexposes embedding-oriented configuration, local observer startup, and batch-shapedAgentSystem::stepfor serverless platforms.stores.rscentralizes ancestor, compaction, deduplication, snapshot, and restore behavior. The daemon store wraps it with persisted extras.Behavior worth reviewing closely
StateStore::should_wake_thread_for_eventprevents stale callbacks, tool results, OAuth responses, and choices from creating unknown or shut-down threads. User text remains able to create threads. Errors fail open.RunningSystem::thread_lifecycleemitsLiveandIdleat the same points the router mutates its live set. The daemon keeps subscribed threads active for RAP server lifetime even though their drivers may idle.LocalSet; the final no-await channel checks make exit atomic with respect to routing. Input either reaches the existing driver or observes closed channels and causes a respawn.CompletionFinishedand tool dispatch. Failed dispatch enqueues an error tool result so the agent can recover.group_id, deferral is applied sequentially per thread, and thread slices run concurrently.Protocol foundations
infinity-rap-bridgeprovides callback conversion, prepared deduplication IDs, callback serving, and view-update forwarding for daemon and Lambda embeddings.infinity-mcp-bridgeprovides lazy stdio and Streamable HTTP clients plus canonical metadata and dispatch used by the daemon proxy.invoke_rap_toolis the shared RAP invocation path used by core, Lambda, and daemon tools, including a uniform non-2xx error result.RapToolSetandMcpToolSetadapters are deferred to feat(infinity-agent-core)!: add high-level agent system API #92.Production migrations
AgentSystem::step; per-session tools resolve throughThreadConfigSource; the Rustrap-receiveruses shared callback conversion and replaces the JavaScript receiver.DisplayEventmoves to the CLI because rendering is no longer a core engine concern.Diff orientation
The new core system modules include the migrated daemon fidelity tests and shared fixtures. The daemon itself shrinks substantially because
agent_loop.rsandthread_worker.rsare removed. Application conveniences and the documentation rewrite are kept out of this PR so reviewers can focus on the engine and production migrations.Validation
cargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspaceBreaking changes
batch_processor(process_batch,process_input_item, and coreDisplayEvent) in favor ofAgentSystem::stepand observer-based local execution.Threadis internal andAgentSystemis notClone.ThreadObserverreplaces inline daemon persistence/display hooks; it has noon_commit.EventCollector::takereturns(thread_id, event)pairs.Rc;Toolgains defaultedis_passive.StateStoregains providedshould_wake_thread_for_event.ToolContextand its builder loseinput_queue_arn.RunningSystem,SubscribeHandle,ChannelSender, andChannelSendErrorlive undersystem::local.boot_rap_servers.rap_callback::start_callback_serveris replaced byinfinity_daemon::launch_session_manager; callback serving accepts aRapCallbackBridge.SessionManager::switch_modelaccepts the requester's sender and returnsResult<(), String>;send_inputacceptsuser_driven: bool;SharedSessionManagerisRc.DisplayEventlives ininfinity_agent_cli::display.