This repository was archived by the owner on Sep 11, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
feat: stream agent events via subscriptions #875
Merged
Merged
Conversation
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
29642ec
to
93c2d20
Compare
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this 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 introduces support for streaming agent events via GraphQL Subscriptions over SSE and enables automatic passivation in the actor system. Key changes include:
- Adding a new GraphQL Subscription schema and SSE logic in the GraphQL handler.
- Introducing a host function “publishEvent” and an events data source for agent events.
- Refining the actor system initialization to support passivation and experimental cluster mode.
Reviewed Changes
Copilot reviewed 40 out of 40 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
runtime/httpserver/health.go | Replaces custom JSON header writing with explicit header setting. |
runtime/hostfunctions/agents.go | Registers a new "publishEvent" host function. |
runtime/graphql/schemagen/* | Adds new GraphQL schema types for agent events. |
runtime/graphql/graphql.go | Implements SSE streaming logic for GraphQL subscriptions. |
runtime/graphql/engine/engine.go | Updates datasource configuration types. |
runtime/graphql/datasource/* | Refactors datasource planner and adds events and functions data sources. |
runtime/actors/* | Updates agent actor lifecycle methods and introduces subscription actors. |
runtime/actors/actorsystem.go | Adds experimental cluster mode configuration with dynamic port allocation. |
CHANGELOG.md | Documents the new streaming agent events feature. |
Comments suppressed due to low confidence (2)
runtime/actors/actorsystem.go:52
- Using dynamically allocated ports for cluster mode may work for testing, but consider making port configuration explicit for production deployments to ensure consistency and reliable discovery.
ports := dynaport.Get(3)
runtime/graphql/datasource/eventsds.go:44
- Since the subscription field name 'agentEvent' is used in multiple places, consider defining it as a constant to avoid potential typos and ensure consistency.
if subName := ci.FieldInfo.Name; subName != "agentEvent" {
danstarns
reviewed
Jun 8, 2025
danstarns
reviewed
Jun 8, 2025
danstarns
reviewed
Jun 8, 2025
danstarns
reviewed
Jun 8, 2025
danstarns
added a commit
to hypermodeinc/docs
that referenced
this pull request
Jun 8, 2025
kevinmingtarja
approved these changes
Jun 9, 2025
danstarns
added a commit
to hypermodeinc/docs
that referenced
this pull request
Jun 24, 2025
* start change to 0.18 * docs: * * docs: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * add events to agents * * * * * * * add note about the rest of agent fields * use any over map interface * use accumulatedReports over context * more error handling * pass non null data around * remove repeated workflow list * * * * * * * sync to support sub hypermodeinc/modus#875 * * * add start stop based on hypermodeinc/modus#889 * trunk... * updates first modus agent * * * * --------- Co-authored-by: Ryan Fox-Tyler <[email protected]> Co-authored-by: William Lyon <[email protected]>
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.
Adds support for streaming events from agents via GraphQL Subscriptions over Server Sent Events (SSE).
The primary API exposed to the user is
PublishEvent
, which is a method on the agent they implement, along with a type definition for their custom events. Events can only be published from an agent - not directly from a function. The runtime will also emit status events for the agent automatically. In the future, there may be other types of events emitted.To test:
agents
example, from either the Go or AssemblyScript SDK.countUpdated
events.This PR also enables "passivation" in the actor system - which will automatically suspend the agent after 10 seconds of inactivity, and resume it automatically when needed.
There's also some bits in this PR for testing GoAkt's cluster mode, but that is unused for now and can be ignored safely. We'll expand on that in a future release.
Postman Instructions
In Postman, if you add a request of type GraphQL, its subscriptions will presume you are using WebSockets and the request will fail (since we use SSE). See postmanlabs/postman-app-support#13416
Instead, add a regular HTTP connection. Set the HTTP verb to
POST
, and select the GraphQL option when pasting the body, which should be as follows:Pass the variable containing the agent ID like this:
It should look like this:
Additionally, on the request headers, set
Accept
totext/event-stream
to enable SSE.Example event stream you can expect to receive (note, postman shows newest events on top):
Expected Client Usage
The implementation conforms to the GraphQL-SSE draft spec. Popular web clients should be able to follow the client usage recipes.
For example, if using
urql
, the urql subscription docs describe how to set up and use a "subscription exchange", and the urql section of the graphql-sse docs explain how to create a GraphQL-SSE based exchange that's compatible with urql.