@mariozechner/pi-agent-core 0.48.0 → 0.49.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -8
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -144,14 +144,28 @@ const agent = new Agent({
|
|
|
144
144
|
// Transform context before convertToLlm (for pruning, compaction)
|
|
145
145
|
transformContext: async (messages, signal) => pruneOldMessages(messages),
|
|
146
146
|
|
|
147
|
-
//
|
|
148
|
-
|
|
147
|
+
// Steering mode: "one-at-a-time" (default) or "all"
|
|
148
|
+
steeringMode: "one-at-a-time",
|
|
149
|
+
|
|
150
|
+
// Follow-up mode: "one-at-a-time" (default) or "all"
|
|
151
|
+
followUpMode: "one-at-a-time",
|
|
149
152
|
|
|
150
153
|
// Custom stream function (for proxy backends)
|
|
151
154
|
streamFn: streamProxy,
|
|
152
155
|
|
|
156
|
+
// Session ID for provider caching
|
|
157
|
+
sessionId: "session-123",
|
|
158
|
+
|
|
153
159
|
// Dynamic API key resolution (for expiring OAuth tokens)
|
|
154
160
|
getApiKey: async (provider) => refreshToken(),
|
|
161
|
+
|
|
162
|
+
// Custom thinking budgets for token-based providers
|
|
163
|
+
thinkingBudgets: {
|
|
164
|
+
minimal: 128,
|
|
165
|
+
low: 512,
|
|
166
|
+
medium: 1024,
|
|
167
|
+
high: 2048,
|
|
168
|
+
},
|
|
155
169
|
});
|
|
156
170
|
```
|
|
157
171
|
|
|
@@ -206,6 +220,19 @@ agent.clearMessages();
|
|
|
206
220
|
agent.reset(); // Clear everything
|
|
207
221
|
```
|
|
208
222
|
|
|
223
|
+
### Session and Thinking Budgets
|
|
224
|
+
|
|
225
|
+
```typescript
|
|
226
|
+
agent.sessionId = "session-123";
|
|
227
|
+
|
|
228
|
+
agent.thinkingBudgets = {
|
|
229
|
+
minimal: 128,
|
|
230
|
+
low: 512,
|
|
231
|
+
medium: 1024,
|
|
232
|
+
high: 2048,
|
|
233
|
+
};
|
|
234
|
+
```
|
|
235
|
+
|
|
209
236
|
### Control
|
|
210
237
|
|
|
211
238
|
```typescript
|
|
@@ -222,26 +249,45 @@ const unsubscribe = agent.subscribe((event) => {
|
|
|
222
249
|
unsubscribe();
|
|
223
250
|
```
|
|
224
251
|
|
|
225
|
-
##
|
|
252
|
+
## Steering and Follow-up
|
|
226
253
|
|
|
227
|
-
|
|
254
|
+
Steering messages let you interrupt the agent while tools are running. Follow-up messages let you queue work after the agent would otherwise stop.
|
|
228
255
|
|
|
229
256
|
```typescript
|
|
230
|
-
agent.
|
|
257
|
+
agent.setSteeringMode("one-at-a-time");
|
|
258
|
+
agent.setFollowUpMode("one-at-a-time");
|
|
231
259
|
|
|
232
260
|
// While agent is running tools
|
|
233
|
-
agent.
|
|
261
|
+
agent.steer({
|
|
234
262
|
role: "user",
|
|
235
263
|
content: "Stop! Do this instead.",
|
|
236
264
|
timestamp: Date.now(),
|
|
237
265
|
});
|
|
266
|
+
|
|
267
|
+
// After the agent finishes its current work
|
|
268
|
+
agent.followUp({
|
|
269
|
+
role: "user",
|
|
270
|
+
content: "Also summarize the result.",
|
|
271
|
+
timestamp: Date.now(),
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
const steeringMode = agent.getSteeringMode();
|
|
275
|
+
const followUpMode = agent.getFollowUpMode();
|
|
276
|
+
|
|
277
|
+
agent.clearSteeringQueue();
|
|
278
|
+
agent.clearFollowUpQueue();
|
|
279
|
+
agent.clearAllQueues();
|
|
238
280
|
```
|
|
239
281
|
|
|
240
|
-
|
|
282
|
+
Use clearSteeringQueue, clearFollowUpQueue, or clearAllQueues to drop queued messages.
|
|
283
|
+
|
|
284
|
+
When steering messages are detected after a tool completes:
|
|
241
285
|
1. Remaining tools are skipped with error results
|
|
242
|
-
2.
|
|
286
|
+
2. Steering messages are injected
|
|
243
287
|
3. LLM responds to the interruption
|
|
244
288
|
|
|
289
|
+
Follow-up messages are checked only when there are no more tool calls and no steering messages. If any are queued, they are injected and another turn runs.
|
|
290
|
+
|
|
245
291
|
## Custom Message Types
|
|
246
292
|
|
|
247
293
|
Extend `AgentMessage` via declaration merging:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mariozechner/pi-agent-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.1",
|
|
4
4
|
"description": "General-purpose agent with transport abstraction, state management, and attachment support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"prepublishOnly": "npm run clean && npm run build"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@mariozechner/pi-ai": "^0.
|
|
21
|
-
"@mariozechner/pi-tui": "^0.
|
|
20
|
+
"@mariozechner/pi-ai": "^0.49.1",
|
|
21
|
+
"@mariozechner/pi-tui": "^0.49.1"
|
|
22
22
|
},
|
|
23
23
|
"keywords": [
|
|
24
24
|
"ai",
|