fix(agent): preserve proxy stream options closes #3512
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `streamProxy()` to preserve the proxy-safe serializable subset of stream options, including session, transport, retry-delay, metadata, header, cache-retention, and thinking-budget settings ([#3512](https://github.com/badlogic/pi-mono/issues/3512))
|
||||
- Fixed parallel tool execution to emit `tool_execution_end` as soon as each tool is finalized, while still emitting persisted tool-result messages in assistant source order ([#3503](https://github.com/badlogic/pi-mono/issues/3503))
|
||||
|
||||
## [0.68.0] - 2026-04-20
|
||||
|
||||
@@ -56,7 +56,23 @@ export type ProxyAssistantMessageEvent =
|
||||
usage: AssistantMessage["usage"];
|
||||
};
|
||||
|
||||
export interface ProxyStreamOptions extends SimpleStreamOptions {
|
||||
type ProxySerializableStreamOptions = Pick<
|
||||
SimpleStreamOptions,
|
||||
| "temperature"
|
||||
| "maxTokens"
|
||||
| "reasoning"
|
||||
| "cacheRetention"
|
||||
| "sessionId"
|
||||
| "headers"
|
||||
| "metadata"
|
||||
| "transport"
|
||||
| "thinkingBudgets"
|
||||
| "maxRetryDelayMs"
|
||||
>;
|
||||
|
||||
export interface ProxyStreamOptions extends ProxySerializableStreamOptions {
|
||||
/** Local abort signal for the proxy request */
|
||||
signal?: AbortSignal;
|
||||
/** Auth token for the proxy server */
|
||||
authToken: string;
|
||||
/** Proxy server URL (e.g., "https://genai.example.com") */
|
||||
@@ -82,6 +98,21 @@ export interface ProxyStreamOptions extends SimpleStreamOptions {
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
function buildProxyRequestOptions(options: ProxyStreamOptions): ProxySerializableStreamOptions {
|
||||
return {
|
||||
temperature: options.temperature,
|
||||
maxTokens: options.maxTokens,
|
||||
reasoning: options.reasoning,
|
||||
cacheRetention: options.cacheRetention,
|
||||
sessionId: options.sessionId,
|
||||
headers: options.headers,
|
||||
metadata: options.metadata,
|
||||
transport: options.transport,
|
||||
thinkingBudgets: options.thinkingBudgets,
|
||||
maxRetryDelayMs: options.maxRetryDelayMs,
|
||||
};
|
||||
}
|
||||
|
||||
export function streamProxy(model: Model<any>, context: Context, options: ProxyStreamOptions): ProxyMessageEventStream {
|
||||
const stream = new ProxyMessageEventStream();
|
||||
|
||||
@@ -127,11 +158,7 @@ export function streamProxy(model: Model<any>, context: Context, options: ProxyS
|
||||
body: JSON.stringify({
|
||||
model,
|
||||
context,
|
||||
options: {
|
||||
temperature: options.temperature,
|
||||
maxTokens: options.maxTokens,
|
||||
reasoning: options.reasoning,
|
||||
},
|
||||
options: buildProxyRequestOptions(options),
|
||||
}),
|
||||
signal: options.signal,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user