This repository was archived by the owner on Sep 11, 2025. It is now read-only.
fix: start agents synchronously, and add examples setting data on start#890
Merged
mattjohnsonpint merged 5 commits intomainfrom Jun 11, 2025
Conversation
Contributor
There was a problem hiding this comment.
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. |
ryanfoxtyler
approved these changes
Jun 11, 2025
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
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.