can1357/oh-my-pi · error · ToolError

${error.message} (rethrown as ToolError from StructuredSubag

Error message

${error.message} (rethrown as ToolError from StructuredSubagentError)

What it means

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.

Source

Thrown at packages/coding-agent/src/eval/agent-bridge.ts:221

			text,
			...(hasData ? { data } : {}),
			details: {
				agent: result.agent,
				id: result.id,
				...(model !== undefined ? { model } : {}),
				structured,
				...(schemaSource !== undefined ? { schemaSource } : {}),
				...(schemaMode !== undefined ? { schemaMode } : {}),
				...(schemaStatus !== undefined ? { schemaStatus } : {}),
				...(policy.isIsolated ? { isolated: true, changesApplied } : {}),
				...(result.patchPath !== undefined ? { patchPath: result.patchPath } : {}),
				...(result.branchName !== undefined ? { branchName: result.branchName } : {}),
				...(nestedPatches !== undefined ? { nestedPatches } : {}),
				...(isolationSummary !== undefined ? { isolationSummary } : {}),
			},
		};
	} catch (error) {
		if (error instanceof StructuredSubagentError) throw new ToolError(error.message);
		throw error;
	}
}

View on GitHub (pinned to 9690622007)

Solutions

  1. Act on error.message — it is the original StructuredSubagentError text
  2. Check artifacts/recovery info from the correlated run
  3. Update the eval harness and subagent runtime to matching versions
  4. If reproducible, file a bug with the message and eval cell

Example fix

// before: raw internal error leaks to eval
} catch (e) { throw e }
// after: bridge already normalizes; handle the ToolError
try { await runEvalAgent(args, opts) } catch (e) { if (e instanceof ToolError) report(e.message) }
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

null

Try / catch

try { await runEvalAgent(args, opts) } catch (e) { if (/rethrown as ToolError from StructuredSubagentError/.test(e.message)) { handleStructuredSubagentFailure(e.message); } else throw e }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/8f5c027a04f04dfa. Report an issue: GitHub.