A desktop coding agent with free access to frontier models.
TypeScript
fix: name the parent after a failed read
ogsamratee737c949020
diff --git a/apps/server/src/opencode-plugins/omnirush-swarm.test.ts b/apps/server/src/opencode-plugins/omnirush-swarm.test.tsindex 4ca162e4..a01b19d8 100644--- a/apps/server/src/opencode-plugins/omnirush-swarm.test.ts+++ b/apps/server/src/opencode-plugins/omnirush-swarm.test.ts@@ -716,3 +716,29 @@ describe("omnirush swarm plugin: sub-agent model and effort", () => {.toEqual({ providerID: "omnirush", modelID: "gpt-6-astra", variant: "low" });});});++describe("parent session header", () => {+ test("a sub-agent whose session read failed once (an error answer, not a throw) still names its main session on the next request", async () => {+ let failing = true;+ const parents: Record<string, string | null> = { ses_child_x: "ses_main_x", ses_main_x: null };+ const client = {+ session: {+ get: async ({ path }: { path: { id: string } }) => {+ if (failing) return { error: { name: "UnknownError" } };+ return { data: { id: path.id, ...(parents[path.id] ? { parentID: parents[path.id] } : {}) } };+ },+ },+ };+ const directory = await mkdtemp(join(tmpdir(), "omnirush-swarm-"));+ dirs.push(directory);+ const hooks = await OmniRushSwarm({ client, directory });+ const headers = async () => {+ const output = { headers: {} as Record<string, string> };+ await hooks["chat.headers"]({ sessionID: "ses_child_x", model: { id: "gpt-6-astra", providerID: "omnirush" } }, output);+ return output.headers;+ };+ expect(await headers()).toEqual({});+ failing = false;+ expect(await headers()).toEqual({ "x-parent-session-id": "ses_main_x" });+ });+});diff --git a/apps/server/src/opencode-plugins/omnirush-swarm.ts b/apps/server/src/opencode-plugins/omnirush-swarm.tsindex 9a9dea86..d5726e1e 100644--- a/apps/server/src/opencode-plugins/omnirush-swarm.ts+++ b/apps/server/src/opencode-plugins/omnirush-swarm.ts@@ -348,7 +348,10 @@ export const OmniRushSwarm = async (input?: { client?: SwarmClient; directory?:if (known !== undefined) return known;try {const response = await input?.client?.session?.get?.({ path: { id: sessionId } });- const parent = typeof response?.data?.parentID === "string" && response.data.parentID ? response.data.parentID : null;+ // An error answer (no session record) is unknown too: not cached, so the+ // sub-agent's next request still names its main session.+ if (!response?.data || typeof response.data !== "object") return null;+ const parent = typeof response.data.parentID === "string" && response.data.parentID ? response.data.parentID : null;remember(parents, sessionId, parent, MAX_TRACKED_SESSIONS);return parent;} catch {