Skip to content

feat(infinity-agent-core)!: allow spawning subagents with a fresh (no prefix) context - #114

Merged
akainth015 merged 3 commits into
mainfrom
feat/fresh-subagents
Sep 18, 2026
Merged

akainth015 merged 3 commits into
mainfrom
feat/fresh-subagents

Conversation

@akainth015

Copy link
Copy Markdown
Member
  • Add a fresh_context boolean to the spawn_thread tool: when true, the child thread starts with an empty history and sees only the provided instructions, instead of inheriting the parent conversation prefix
  • Introduce SpawnContext (Inherit / InheritUpTo(n) / Fresh) replacing the spawn_order_override: Option<usize> parameter of ConversationStore::spawn_thread
  • Persist freshness as a thread attribute (ThreadInfo::fresh_context, new fresh_context column in the DSQL thread_hierarchy table) and add ConversationStore::is_fresh_context_thread
  • load_history_with_ancestors now truncates the ancestor chain at the deepest fresh boundary, so neither a fresh thread nor its descendants can see context from before the fresh spawn (including grandparents)
  • Seed fresh children with a synthetic spawn_thread tool call in their own store so the instruction tool-result pairs with a matching call
  • Document fresh-context subagents in the default prompt

BREAKING CHANGE: ConversationStore::spawn_thread takes SpawnContext instead of Option<usize>, and implementations must provide is_fresh_context_thread.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 15, 2026

Copy link
Copy Markdown

Deploying infinity with  Cloudflare Pages  Cloudflare Pages

Latest commit: a74c4e7
Status: ✅  Deploy successful!
Preview URL: https://f743c100.infinity-dc7.pages.dev
Branch Preview URL: https://feat-fresh-subagents.infinity-dc7.pages.dev

View logs

@akainth015
akainth015 marked this pull request as ready for review September 15, 2026 21:10
@akainth015
akainth015 requested a review from a team September 15, 2026 21:10
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SpawnContext {
/// Inherit the parent's full history up to the moment of the spawn.
Inherit,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does anyone use this other than tests?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! It's used here in the SpawnThreadTool.

Comment thread crates/infinity-agent-core/src/system/tests.rs
akainth015 and others added 3 commits September 17, 2026 20:23
… prefix) context

* Add a `fresh_context` boolean to the `spawn_thread` tool: when true, the
  child thread starts with an **empty** history and sees only the provided
  instructions, instead of inheriting the parent conversation prefix
* Introduce `SpawnContext` (`Inherit` / `InheritUpTo(n)` / `Fresh`) replacing
  the `spawn_order_override: Option<usize>` parameter of
  `ConversationStore::spawn_thread`
* Persist freshness as a thread attribute (`ThreadInfo::fresh_context`, new
  `fresh_context` column in the DSQL `thread_hierarchy` table) and add
  `ConversationStore::is_fresh_context_thread`
* `load_history_with_ancestors` now truncates the ancestor chain at the
  deepest fresh boundary, so neither a fresh thread nor its descendants can
  see context from before the fresh spawn (including grandparents)
* Seed fresh children with a synthetic `spawn_thread` tool call in their own
  store so the instruction tool-result pairs with a matching call
* Document fresh-context subagents in the default prompt

BREAKING CHANGE: `ConversationStore::spawn_thread` takes `SpawnContext`
instead of `Option<usize>`, and implementations must provide
`is_fresh_context_thread`.

Co-authored-by: Infinity 🤖 <infinity@hydro.run>
…guard to appease clippy 1.95

`clippy::collapsible_match` (denied via `-D warnings`) now fires on the
text-delta branch in `stream.rs`; fold the `tool_call.is_none()` check
into a match guard.

Co-authored-by: Infinity 🤖 <infinity@hydro.run>

@shadaj shadaj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Comment thread crates/infinity-agent-core/src/traits.rs
@akainth015
akainth015 merged commit 10969cf into main Sep 18, 2026
8 checks passed
@akainth015
akainth015 deleted the feat/fresh-subagents branch September 18, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants