@@ -111,13 +111,42 @@ Creates a deep copy of the agent instance.
111111clone (): AbstractAgent
112112```
113113
114+ ### connectAgent()
115+
116+ Establishes a persistent connection with an agent that implements the
117+ ` connect() ` method.
118+
119+ ``` typescript
120+ connectAgent (parameters ?: RunAgentParameters , subscriber ?: AgentSubscriber ): Promise < RunAgentResult >
121+ ```
122+
123+ Similar to ` runAgent() ` but uses the ` connect() ` method internally. The agent
124+ must implement ` connect() ` or this functionality must be provided by a framework
125+ like [ CopilotKit] ( https://copilotkit.ai ) .
126+
127+ ## Observable Properties
128+
129+ ### events$
130+
131+ An observable stream of all events emitted during agent execution.
132+
133+ ``` typescript
134+ events$ : Observable < BaseEvent >
135+ ```
136+
137+ This property provides direct access to the agent's event stream. Events are
138+ stored using a ` ReplaySubject ` , allowing late subscribers will receive all
139+ historical events.
140+
114141## Properties
115142
116143- ` agentId ` : Unique identifier for the agent instance
117144- ` description ` : Human-readable description
118145- ` threadId ` : Conversation thread identifier
119146- ` messages ` : Array of conversation messages
120147- ` state ` : Current agent state object
148+ - ` events$ ` : Observable stream of all ` BaseEvent ` objects emitted during agent
149+ execution (replayed for late subscribers)
121150
122151## Protected Methods
123152
@@ -131,6 +160,17 @@ Executes the agent and returns an observable event stream.
131160protected abstract run (input : RunAgentInput ): RunAgent
132161```
133162
163+ ### connect()
164+
165+ Establishes a persistent connection and returns an observable event stream.
166+
167+ ``` typescript
168+ protected connect (input : RunAgentInput ): RunAgent
169+ ```
170+
171+ Override this method to implement persistent connections. Default implementation
172+ throws ` ConnectNotImplementedError ` .
173+
134174### apply()
135175
136176Processes events from the run and updates the agent state.
0 commit comments