refactor!: extract shared agent system engine - #96
Merged
Conversation
Deploying infinity with
|
| Latest commit: |
2d27833
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://d68c57fd.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
5 times, most recently
from
August 14, 2026 19:15
eed1c6d to
042b309
Compare
shadaj
force-pushed
the
sandbox-0f86f15a-4591-435a-bff7-27a45f33e143
branch
from
August 19, 2026 21:30
042b309 to
74357ca
Compare
| /// the sender, which the step observes as a cancellation. | ||
| struct InFlightStep<'a> { | ||
| fut: StepFuture<'a>, | ||
| cancel_tx: oneshot::Sender<()>, |
Member
There was a problem hiding this comment.
Comment on lines
+28
to
+30
| /// Implementations that need mutable state should use interior mutability | ||
| /// (`RefCell`); the methods take `&self` so the runtime can hold shared | ||
| /// references across a step. |
Member
There was a problem hiding this comment.
I suppose Infinity could wrap in RefCell itself, if this is always expected to be the case
MingweiSamuel
approved these changes
Aug 19, 2026
shadaj
added a commit
that referenced
this pull request
Aug 19, 2026
Move the daemon and Lambda runtimes onto the shared infinity-agent-core engine, including routing, lifecycle, state-store, observer, step-processing, and shutdown behavior. Separate exact thread existence from embedding-specific stopped-thread policy in router admission, and make lifecycle events the source of daemon session activity state. Split MCP and RAP integration foundations 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; ConversationStore gains thread_exists and StateStore replaces should_wake_thread_for_event with is_thread_stopped. Co-authored-by: Infinity 🤖 <infinity@hydro.run> PR: #96
shadaj
force-pushed
the
sandbox-0f86f15a-4591-435a-bff7-27a45f33e143
branch
3 times, most recently
from
August 20, 2026 16:42
22c2fc3 to
cb6fe1b
Compare
MingweiSamuel
approved these changes
Aug 20, 2026
Move the daemon and Lambda runtimes onto the shared infinity-agent-core engine, including routing, lifecycle, state-store, observer, step-processing, and shutdown behavior. Separate exact thread existence from embedding-specific stopped-thread policy in router admission, and make lifecycle events the source of daemon session activity state. Split MCP and RAP integration foundations 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; ConversationStore gains thread_exists and StateStore replaces should_wake_thread_for_event with is_thread_stopped. Co-authored-by: Infinity 🤖 <infinity@hydro.run> PR: #96
shadaj
force-pushed
the
sandbox-0f86f15a-4591-435a-bff7-27a45f33e143
branch
from
August 20, 2026 21:15
cb6fe1b to
2d27833
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, event 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
ConversationStore::thread_existswhether the exact root or child target exists, then asksStateStore::is_thread_stoppedwhether the embedding has explicitly stopped it. Unknown and stopped targets are dropped. User text bypasses both checks because it creates new threads and resumes stopped ones. Store failures fail open so a transient read cannot discard a real tool result.Livelifecycle event resolves the thread's root session and clears both its idle and stopped flags. This applies equally to root and child activity and makes lifecycle the single source of runtime activity state. Event-style input for a stopped session never producesLivebecause router admission drops it first.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. DSQL thread-hierarchy records provide exact event-target existence checks.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.ConversationStoregainsthread_exists, which checks exact root or child records without creating them.StateStoregains the providedis_thread_stoppedpolicy hook. User text may resume stopped threads; event-style input may not.Rc;Toolgains defaultedis_passive.ToolContextand its builder loseinput_queue_arn.RunningSystem,SubscribeHandle,ChannelSender, andChannelSendErrorlive undersystem::local.boot_rap_servers.SessionManager::send_inputno longer accepts a thread ID oruser_drivenflag and performs no status admission; router admission and lifecycle events own those concerns.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>;SharedSessionManagerisRc.DisplayEventlives ininfinity_agent_cli::display.