{"record":{"id":"8f5c027a04f04dfa","repo":"can1357/oh-my-pi","slug":"error-message-rethrown-as-toolerror-from-struc","errorCode":null,"errorMessage":"${error.message} (rethrown as ToolError from StructuredSubagentError)","messagePattern":"(.+?) \\(rethrown as ToolError from StructuredSubagentError\\)","errorType":"exception","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/eval/agent-bridge.ts","lineNumber":221,"sourceCode":"\t\t\ttext,\n\t\t\t...(hasData ? { data } : {}),\n\t\t\tdetails: {\n\t\t\t\tagent: result.agent,\n\t\t\t\tid: result.id,\n\t\t\t\t...(model !== undefined ? { model } : {}),\n\t\t\t\tstructured,\n\t\t\t\t...(schemaSource !== undefined ? { schemaSource } : {}),\n\t\t\t\t...(schemaMode !== undefined ? { schemaMode } : {}),\n\t\t\t\t...(schemaStatus !== undefined ? { schemaStatus } : {}),\n\t\t\t\t...(policy.isIsolated ? { isolated: true, changesApplied } : {}),\n\t\t\t\t...(result.patchPath !== undefined ? { patchPath: result.patchPath } : {}),\n\t\t\t\t...(result.branchName !== undefined ? { branchName: result.branchName } : {}),\n\t\t\t\t...(nestedPatches !== undefined ? { nestedPatches } : {}),\n\t\t\t\t...(isolationSummary !== undefined ? { isolationSummary } : {}),\n\t\t\t},\n\t\t};\n\t} catch (error) {\n\t\tif (error instanceof StructuredSubagentError) throw new ToolError(error.message);\n\t\tthrow error;\n\t}\n}\n","sourceCodeStart":203,"sourceCodeEnd":225,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/eval/agent-bridge.ts#L203-L225","documentation":"At the end of runEvalAgent, any StructuredSubagentError escaping the execution block is rethrown as a ToolError carrying the original message plus a marker noting its origin, so eval tooling sees a consistent tool-error type. The marker distinguishes these from ordinary ToolErrors thrown earlier in the bridge.","triggerScenarios":"Any failure inside the isolated-subagent execution pipeline that raises StructuredSubagentError (structured-output collection, nested patch handling, merge bookkeeping) propagates to this catch and is converted.","commonSituations":"Subagent produced structured output in an unexpected shape; nested-patch pipeline failed below the earlier explicit checks; version drift between the eval harness and subagent runtime changed error classes.","solutions":["Act on error.message — it is the original StructuredSubagentError text","Check artifacts/recovery info from the correlated run","Update the eval harness and subagent runtime to matching versions","If reproducible, file a bug with the message and eval cell"],"exampleFix":"// before: raw internal error leaks to eval\n} catch (e) { throw e }\n// after: bridge already normalizes; handle the ToolError\ntry { await runEvalAgent(args, opts) } catch (e) { if (e instanceof ToolError) report(e.message) }","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try { await runEvalAgent(args, opts) } catch (e) { if (/rethrown as ToolError from StructuredSubagentError/.test(e.message)) { handleStructuredSubagentFailure(e.message); } else throw e }","preventionTips":["Keep eval harness and subagent runtime versions aligned","Validate structured output schemas in the subagent","Log the message verbatim — it carries the root cause","Add an eval-cell regression test after any occurrence"],"tags":["tool-error","subagent","structured-output","eval"],"backgroundTag":"structured-subagent-error","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}