File tree Expand file tree Collapse file tree 2 files changed +51
-7
lines changed Expand file tree Collapse file tree 2 files changed +51
-7
lines changed Original file line number Diff line number Diff line change @@ -53,10 +53,10 @@ class MyAgent extends AbstractAgent {
53
53
54
54
### runAgent()
55
55
56
- The primary method for executing an agent and receiving the event stream .
56
+ The primary method for executing an agent and processing the result .
57
57
58
58
``` typescript
59
- runAgent (parameters ?: RunAgentParameters ): Observable < RuntimeProtocolEvent >
59
+ runAgent (parameters ?: RunAgentParameters , subscriber ?: AgentSubscriber ): Promise < RunAgentResult >
60
60
```
61
61
62
62
#### Parameters
@@ -70,6 +70,31 @@ interface RunAgentParameters {
70
70
}
71
71
```
72
72
73
+ The optional ` subscriber ` parameter allows you to provide an
74
+ [ AgentSubscriber] ( /sdk/js/client/subscriber ) for handling events during this
75
+ specific run.
76
+
77
+ #### Return Value
78
+
79
+ ``` typescript
80
+ interface RunAgentResult {
81
+ result: any // The final result returned by the agent
82
+ newMessages: Message [] // New messages added during this run
83
+ }
84
+ ```
85
+
86
+ ### subscribe()
87
+
88
+ Adds an [ AgentSubscriber] ( /sdk/js/client/subscriber ) to handle events across
89
+ multiple agent runs.
90
+
91
+ ``` typescript
92
+ subscribe (subscriber : AgentSubscriber ): { unsubscribe : () => void }
93
+ ```
94
+
95
+ Returns an object with an ` unsubscribe() ` method to remove the subscriber when
96
+ no longer needed.
97
+
73
98
### abortRun()
74
99
75
100
Cancels the current agent execution.
Original file line number Diff line number Diff line change @@ -39,21 +39,40 @@ const agent = new HttpAgent({
39
39
40
40
### runAgent()
41
41
42
- Executes the agent by making an HTTP request to the configured endpoint. Returns
43
- an observable event stream.
42
+ Executes the agent by making an HTTP request to the configured endpoint.
44
43
45
44
``` typescript
46
- runAgent (parameters ?: RunHttpAgentConfig ): Observable < RuntimeProtocolEvent >
45
+ runAgent (parameters ?: RunAgentParameters , subscriber ?: AgentSubscriber ): Promise < RunAgentResult >
47
46
```
48
47
49
48
#### Parameters
50
49
50
+ The ` parameters ` argument follows the standard ` RunAgentParameters ` interface.
51
+ The optional ` subscriber ` parameter allows you to provide an
52
+ [ AgentSubscriber] ( /sdk/js/client/subscriber ) for handling events during this
53
+ specific run.
54
+
55
+ #### Return Value
56
+
51
57
``` typescript
52
- interface RunHttpAgentConfig extends RunAgentParameters {
53
- abortController? : AbortController // For canceling the HTTP request
58
+ interface RunAgentResult {
59
+ result: any // The final result returned by the agent
60
+ newMessages: Message [] // New messages added during this run
54
61
}
55
62
```
56
63
64
+ ### subscribe()
65
+
66
+ Adds an [ AgentSubscriber] ( /sdk/js/client/subscriber ) to handle events across
67
+ multiple agent runs.
68
+
69
+ ``` typescript
70
+ subscribe (subscriber : AgentSubscriber ): { unsubscribe : () => void }
71
+ ```
72
+
73
+ Returns an object with an ` unsubscribe() ` method to remove the subscriber when
74
+ no longer needed.
75
+
57
76
### abortRun()
58
77
59
78
Cancels the current HTTP request using the AbortController.
You can’t perform that action at this time.
0 commit comments