Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Conversation

@mattjohnsonpint
Copy link
Contributor

When starting an agent, it's a common need to set initial data. The easiest way to do this is by passing a message immediately after starting the agent. However, previously, there could be a race condition wherein the actor was not yet ready to receive the message because it was being started asynchronously.

This changes the normal agent startup to be synchronous, so immediately after starting an agent, the agent is guaranteed to be running.

Added some tests to prove it works.

Resuming agents on startup or reload will still be async.

@mattjohnsonpint mattjohnsonpint requested review from a team and Copilot June 11, 2025 21:58
@linear
Copy link

linear bot commented Jun 11, 2025

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a race condition by changing agent startup from asynchronous to synchronous and adds examples for starting agents with initial data. Key changes include:

  • Adding new functions (StartCounterAgentWithData) in Go and AssemblyScript examples that set initial count data.
  • Updating the agent startup flow in the runtime to use synchronous spawning.
  • Adjusting the changelog to document these updates.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
sdk/go/examples/agents/main.go Adds a function to start a counter agent with initial data.
sdk/assemblyscript/examples/agents/assembly/index.ts Provides an AssemblyScript example for starting an agent with initial data.
runtime/actors/agents.go Refactors agent startup to be synchronous using spawnActorForAgent.
runtime/actors/actorsystem.go Adjusts actor restart and spawning in goroutines to support synchronous startup.
CHANGELOG.md Updates changelog with the new sync startup feature.

@mattjohnsonpint mattjohnsonpint enabled auto-merge (squash) June 11, 2025 22:07
@mattjohnsonpint mattjohnsonpint merged commit 6aaedc0 into main Jun 11, 2025
87 checks passed
@mattjohnsonpint mattjohnsonpint deleted the mjp/hyp-3422-need-ability-to-send-initial-data-when-starting-an-agent branch June 11, 2025 22:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants