Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .pylon/upstream-review.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,3 +427,28 @@ after exact owned cleanup and supervisor exit. Pylon delivery tracked in [pylon#
| TUI / CLI UI / CI: #2446, #2447, #2430, #2466, #2340, #2331, #2328, #2324, #2325, #2301, #2302, #2306, #2449, #2376, #2456, #2323 | Terminal UI interactions, upstream CI/benchmarks, install docs | **Skip** | Prime-specific TUI screens, terminal commands, and upstream internal CI are not consumed by Pylon web/desktop/mobile clients. No daemon protocol or SDK impact. Revisit if features move to daemon protocol. |
| #2458 (`2e9ab77b8`) | Reconnect attached windows when daemon restarts | **Skip / Retain** | TUI client window reconnect is skipped because Pylon manages its own reconnection; supervisor update-restart phase closing reason is retained/deferred with supervisor lifecycle audit. |
| Distribution: #2366, #2370, #2369, #2368, #2361, #2344, #2319 | Native binaries, updater manifests, musl packages | **Retain** | Retain Pylon recipe 2 deterministic SDK archives per fork #75 decision. Revisit if upstream provides importable Node SDK in binary archives. |

## 2026-09-26 — post-v0.9.5 through v0.9.6 upstream review (18a56bf35..cd1f215cf)

- Review range: upstream commits `18a56bf3557063c0cd0be12f99f0bcce2a46da32..cd1f215cfc6604470c1f6d3f2ecbfca3006497f3` (45 commits, including release v0.9.6 `e260085dd` and post-release TUI commits `80c51e460`, `cd1f215cf`).
- Merge-base and complete integration checkpoint remain frozen at v0.9.4 `1eee2938b4eeb7a4d72e17035adda669a89b63de`.
- Adversarial triage completed across all 45 candidate commits.

### Dispositions and Revisit Triggers

| PR / Commit | Subject / Area | Disposition | Notes & Revisit Triggers |
| --- | --- | --- | --- |
| #2508 (`a0660bb5f`) | Worker client socket release on failed connect | **Adopt (Hardened)** | Releases stale socket references on connect timeout or rejection. Hardened in fork to attach trailing error sink before socket destruction to avoid unhandled Node exception crashes. |
| #2474 (`cc55bb11a`) | Provider retry backoff jitter (\+/-25%) | **Adopt** | De-synchronizes concurrent retry storms while strictly flooring delays at server-mandated `Retry-After` headers. |
| #2500 (`0e3c90022`) | Kernel error text cap and host_request size bounds | **Adopt** | Caps kernel execution error text to 1MB and rejects oversized host_request payloads to prevent memory exhaustion and IPC deadlocks. |
| #2499 (`5062b1b31`) | Python skills key matching `(importName, packagePath)` | **Adopt** | Prevents spurious skill venv re-synchronization when skills share import namespaces across distinct packages. |
| #2491 (`fb8d7411e`) | Proxy stream truncation detection & serviceTier forwarding | **Adopt** | Propagates premature proxy stream EOF as terminal stream errors and preserves OpenAI `serviceTier` parameter across proxy boundaries. |
| #2533, #2555, #2560 (`1e2cc2278`, `b11fd5e2d`, `346a463da`) | Claude Opus 5.5 adaptive thinking | **Adopt** | Configures always-on adaptive thinking and test fixture surfaces for Claude Opus 5.5. |
| #2645 (`703cc4547`) | Claude Code client version bump (2.1.281) & ban risk notice | **Adopt** | Claims client version 2.1.281 for Anthropic subscription OAuth requests to pass backend model gating, accompanied by user-facing ban-risk warning. |
| #2507 (`36b912fea`) | Remote catalog fetch from `prime-agent-catalog` | **Hold / Audit** | Introduces runtime network dependency for model metadata. Held pending evaluation of offline cache fallbacks and deterministic air-gapped guarantees. |
| #2475 (`561401b27`) | Truncate cell source to 2KB on `host_request` | **Hold / Audit** | May break downstream provenance reconstruction and context hash verification when cells exceed 2KB. Held for Pylon trace analysis. |
| #2382 (`d73349d50`) | Raw `child.kill("SIGKILL")` on worker bridge EPIPE | **Reject** | Violates Pylon syscall safety invariant; raw signals to unverified PIDs risk killing recycled processes during rapid worker crashes. Must rely on supervised process exit receipts. |
| #2471 (`8ee46be35`), #2478 (`02e5babb4`) | Live mutation of CPython `__closure__` and `__globals__` | **Reject** | Unsafe runtime bytecode/closure mutation in REPL state restore risks memory leaks and CPython interpreter `SIGSEGV` crashes. |
| #2388 (`1c1ad1e48`) | Synchronous session name reclamation on delete receipt | **Reject** | Deleting session name before child process unwinding completes creates race conditions with pending detached worker handles. |
| #2334, #2465 | Human priority queue reordering & continuation holds | **Fenced** | Fenced per Issue #727 empirical findings. Pylon daemon adapter enforces FIFO cursor monotonicity; reordering causes frame drop and transcript desync. |
| TUI / Internal CI (23 commits) | Terminal UI styling, upstream release benchmarks, packaging | **Skip** | Prime-specific TUI screens, terminal commands, and internal CI workflows not consumed by Pylon web/desktop/mobile hosts. |
1 change: 1 addition & 0 deletions packages/agent/.changes/fix-proxy-eof.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Proxy streams now fail with a clear "stream truncated" error instead of hanging forever when the connection ends mid-response, and the proxy request body is derived from the shared stream-options type so new options cannot be silently dropped.
51 changes: 38 additions & 13 deletions packages/agent/src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,35 @@ export type ProxyAssistantMessageEvent =
usage: AssistantMessage["usage"];
};

type ProxySerializableStreamOptions = Pick<
SimpleStreamOptions,
| "temperature"
| "maxTokens"
| "reasoning"
| "cacheRetention"
| "sessionId"
| "headers"
| "metadata"
| "transport"
| "thinkingBudgets"
>;
/**
* Total map over the shared stream options: every option is either serialized into the proxy
* request or explicitly excluded. A new option in `SimpleStreamOptions` fails to compile here
* until it is classified, so proxy transport cannot silently drop what direct transport sends.
*/
const PROXY_SERIALIZED_OPTIONS = {
temperature: true,
maxTokens: true,
reasoning: true,
cacheRetention: true,
sessionId: true,
headers: true,
metadata: true,
transport: true,
thinkingBudgets: true,
serviceTier: true,
// Client-local: abort, credentials, request lifetime and payload hooks stay on this side.
signal: false,
apiKey: false,
timeoutMs: false,
onPayload: false,
onResponse: false,
} as const satisfies Record<keyof SimpleStreamOptions, boolean>;

type ProxySerializedOption = {
[K in keyof typeof PROXY_SERIALIZED_OPTIONS]: (typeof PROXY_SERIALIZED_OPTIONS)[K] extends true ? K : never;
}[keyof typeof PROXY_SERIALIZED_OPTIONS];

type ProxySerializableStreamOptions = Pick<SimpleStreamOptions, ProxySerializedOption>;

export interface ProxyStreamOptions extends ProxySerializableStreamOptions {
signal?: AbortSignal;
Expand All @@ -84,7 +101,9 @@ export interface ProxyStreamOptions extends ProxySerializableStreamOptions {
* });
* ```
*/
function buildProxyRequestOptions(options: ProxyStreamOptions): ProxySerializableStreamOptions {
function buildProxyRequestOptions(options: ProxyStreamOptions): {
[K in ProxySerializedOption]: SimpleStreamOptions[K];
} {
return {
temperature: options.temperature,
maxTokens: options.maxTokens,
Expand All @@ -95,6 +114,7 @@ function buildProxyRequestOptions(options: ProxyStreamOptions): ProxySerializabl
metadata: options.metadata,
transport: options.transport,
thinkingBudgets: options.thinkingBudgets,
serviceTier: options.serviceTier,
};
}

Expand All @@ -121,6 +141,7 @@ export function streamProxy(model: Model<any>, context: Context, options: ProxyS
};

let reader: ReadableStreamDefaultReader<Uint8Array> | undefined;
let sawTerminalEvent = false;

const abortHandler = () => {
if (reader) {
Expand Down Expand Up @@ -183,6 +204,7 @@ export function streamProxy(model: Model<any>, context: Context, options: ProxyS
const proxyEvent = JSON.parse(data) as ProxyAssistantMessageEvent;
const event = processProxyEvent(proxyEvent, partial);
if (event) {
sawTerminalEvent ||= event.type === "done" || event.type === "error";
stream.push(event);
}
}
Expand All @@ -193,6 +215,9 @@ export function streamProxy(model: Model<any>, context: Context, options: ProxyS
if (options.signal?.aborted) {
throw new Error("Request aborted by user");
}
if (!sawTerminalEvent) {
throw new Error("Proxy stream truncated before completion");
}

stream.end();
} catch (error) {
Expand Down
29 changes: 29 additions & 0 deletions packages/agent/test/proxy.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { getModels } from "@earendil-works/pi-ai";
import { afterEach, expect, it, vi } from "vitest";
import { streamProxy } from "../src/proxy.js";

const model = getModels("openai")[0];
const proxyOptions = { authToken: "token", proxyUrl: "http://proxy.test" };

function stubProxyResponse(sse: string): { options: { serviceTier?: string } }[] {
const sent: { options: { serviceTier?: string } }[] = [];
vi.stubGlobal("fetch", async (_url: string, init: RequestInit) => {
sent.push(JSON.parse(String(init.body)));
return new Response(sse, { status: 200 });
});
return sent;
}

afterEach(() => vi.unstubAllGlobals());

it("settles a truncated proxy stream with an error result", async () => {
stubProxyResponse('data: {"type":"start"}\n\n');
const result = await streamProxy(model, { messages: [] }, proxyOptions).result();
expect(result).toMatchObject({ stopReason: "error", errorMessage: expect.stringContaining("truncated") });
});

it("serializes serviceTier into the proxy request", async () => {
const sent = stubProxyResponse("");
await streamProxy(model, { messages: [] }, { ...proxyOptions, serviceTier: "priority" }).result();
expect(sent[0]?.options.serviceTier).toBe("priority");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Bumped the Claude Code client version claimed by Anthropic subscription (OAuth) requests from 2.1.261 to 2.1.281: the API gates newer models on the claimed client version and rejects claude-opus-5.5 (and other gated models) with a 400 for anything below 2.280.
2 changes: 2 additions & 0 deletions packages/ai/.changes/opus-5-5-always-on-adaptive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Claude Opus 5.5 is always-on adaptive like the Fable/Mythos models: it rejects `thinking: {type: "disabled"}` and non-default sampling params with a 400, so the Anthropic and Bedrock providers stop sending both and the thinking-payload tests cover the release id.
- The model rows themselves ship from the prime-agent-catalog repo (add model: claude-opus-5-5, gpt-6-sol, gpt-6-luna); no compiled-catalog regen is needed.
12 changes: 10 additions & 2 deletions packages/ai/src/providers/amazon-bedrock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,11 +508,19 @@ function supportsAdaptiveThinking(modelId: string, modelName?: string): boolean
}

/**
* Fable/Mythos models think every turn and reject sampling params with a 400.
* Fable/Mythos models — and Claude Opus 5.5 — think every turn and reject
* sampling params with a 400.
*/
function supportsAlwaysOnAdaptiveThinking(modelId: string, modelName?: string): boolean {
const candidates = getModelMatchCandidates(modelId, modelName);
return candidates.some((s) => s.includes("fable-5") || s.includes("mythos-5") || s.includes("mythos-preview"));
return candidates.some(
(s) =>
s.includes("fable-5") ||
s.includes("mythos-5") ||
s.includes("mythos-preview") ||
s.includes("opus-5-5") ||
s.includes("opus-5.5"),
);
}

function mapThinkingLevelToEffort(
Expand Down
16 changes: 12 additions & 4 deletions packages/ai/src/providers/anthropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ function getCacheControl(
}

// Stealth mode: Mimic Claude Code's tool naming exactly
const claudeCodeVersion = "2.1.261";
// The API gates newer models on the claimed client version (e.g. claude-opus-5.5
// requires >= 2.280), so keep this at or above the latest released Claude Code.
const claudeCodeVersion = "2.1.281";

// Claude Code 2.x tool names (canonical casing)
// Source: https://cchistory.mariozechner.at/data/prompts-2.1.11.md
Expand Down Expand Up @@ -764,11 +766,17 @@ export const streamAnthropic: StreamFunction<"anthropic-messages", AnthropicOpti
};

/**
* Fable/Mythos models think every turn and reject an explicit
* `thinking: {type: "disabled"}` (and any sampling params) with a 400.
* Fable/Mythos models — and Claude Opus 5.5 — think every turn and reject an
* explicit `thinking: {type: "disabled"}` (and any sampling params) with a 400.
*/
function isAlwaysOnAdaptiveThinkingModel(modelId: string): boolean {
return modelId.includes("fable-5") || modelId.includes("mythos-5") || modelId.includes("mythos-preview");
return (
modelId.includes("fable-5") ||
modelId.includes("mythos-5") ||
modelId.includes("mythos-preview") ||
modelId.includes("opus-5-5") ||
modelId.includes("opus-5.5")
);
}

/**
Expand Down
Loading
Loading