@oh-my-pi/pi-agent-core 14.6.1 → 14.6.3

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/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [14.6.2] - 2026-05-03
6
+
7
+ ### Fixed
8
+
9
+ - Fixed unhandled promise rejection when `getApiKey` or any other async error occurs during `streamAssistantResponse`: agent loop IIFEs now catch and route errors through `EventStream.fail()`, which terminates the `for await` loop and lets `Agent#runLoop`'s catch block create a proper error assistant message instead of crashing
10
+
5
11
  ## [14.6.0] - 2026-05-02
6
12
  ### Fixed
7
13
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@oh-my-pi/pi-agent-core",
4
- "version": "14.6.1",
4
+ "version": "14.6.3",
5
5
  "description": "General-purpose agent with transport abstraction, state management, and attachment support",
6
6
  "homepage": "https://github.com/can1357/oh-my-pi",
7
7
  "author": "Can Boluk",
@@ -35,9 +35,9 @@
35
35
  "fmt": "biome format --write ."
36
36
  },
37
37
  "dependencies": {
38
- "@oh-my-pi/pi-ai": "14.6.1",
39
- "@oh-my-pi/pi-natives": "14.6.1",
40
- "@oh-my-pi/pi-utils": "14.6.1"
38
+ "@oh-my-pi/pi-ai": "14.6.3",
39
+ "@oh-my-pi/pi-natives": "14.6.3",
40
+ "@oh-my-pi/pi-utils": "14.6.3"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@sinclair/typebox": "^0.34.49",
package/src/agent-loop.ts CHANGED
@@ -49,7 +49,11 @@ export function agentLoop(
49
49
  stream.push({ type: "message_end", message: prompt });
50
50
  }
51
51
 
52
- await runLoop(currentContext, newMessages, config, signal, stream, streamFn);
52
+ try {
53
+ await runLoop(currentContext, newMessages, config, signal, stream, streamFn);
54
+ } catch (err) {
55
+ stream.fail(err);
56
+ }
53
57
  })();
54
58
 
55
59
  return stream;
@@ -86,7 +90,11 @@ export function agentLoopContinue(
86
90
  stream.push({ type: "agent_start" });
87
91
  stream.push({ type: "turn_start" });
88
92
 
89
- await runLoop(currentContext, newMessages, config, signal, stream, streamFn);
93
+ try {
94
+ await runLoop(currentContext, newMessages, config, signal, stream, streamFn);
95
+ } catch (err) {
96
+ stream.fail(err);
97
+ }
90
98
  })();
91
99
 
92
100
  return stream;
@@ -339,10 +347,12 @@ async function streamAssistantResponse(
339
347
  (config.getApiKey ? await config.getApiKey(config.model.provider) : undefined) || config.apiKey;
340
348
 
341
349
  const dynamicToolChoice = config.getToolChoice?.();
350
+ const dynamicReasoning = config.getReasoning?.();
342
351
  const response = await streamFunction(config.model, llmContext, {
343
352
  ...config,
344
353
  apiKey: resolvedApiKey,
345
354
  toolChoice: dynamicToolChoice ?? config.toolChoice,
355
+ reasoning: dynamicReasoning ?? config.reasoning,
346
356
  signal,
347
357
  });
348
358
 
package/src/agent.ts CHANGED
@@ -784,6 +784,7 @@ export class Agent {
784
784
  intentTracing: this.#intentTracing,
785
785
  onAssistantMessageEvent: this.#onAssistantMessageEvent,
786
786
  getToolChoice,
787
+ getReasoning: () => this.#state.thinkingLevel,
787
788
  getSteeringMessages: async () => {
788
789
  if (skipInitialSteeringPoll) {
789
790
  skipInitialSteeringPoll = false;
package/src/types.ts CHANGED
@@ -145,6 +145,14 @@ export interface AgentLoopConfig extends SimpleStreamOptions {
145
145
  * When set and returns a value, overrides the static `toolChoice`.
146
146
  */
147
147
  getToolChoice?: () => ToolChoice | undefined;
148
+
149
+ /**
150
+ * Dynamic reasoning effort override, resolved per LLM call.
151
+ * When set and returns a value, overrides the static `reasoning` captured
152
+ * at run-loop start. Use this so mid-run thinking-level changes apply on
153
+ * the next model call instead of waiting for the next prompt.
154
+ */
155
+ getReasoning?: () => Effort | undefined;
148
156
  }
149
157
 
150
158
  export interface ToolCallContext {