functions.exec silently discards un-emitted nested tool results and artifact handles

Open 💬 2 comments Opened Jul 11, 2026 by mading0817

Summary

functions.exec silently discards the complete result of an awaited nested tool call when the script does not explicitly emit it with text(...). The outer call still reports Script completed, which can make an agent believe a producer returned empty stdout and can permanently lose exact artifact handles.

This is especially risky for custom subagents and artifact-first workflows where the producer returns a unique run_id or exact artifact path only in its stdout envelope.

Minimal reproduction

Result silently lost

await tools.exec_command({
  cmd: "Write-Output 'NESTED_OUTPUT_NOT_FORWARDED_MARKER'",
  yield_time_ms: 10000,
  max_output_tokens: 1000
});

Observed:

Script completed
Output:

The nested command did execute successfully, but stdout and the rest of the returned object are silently discarded.

Explicit forwarding works

const result = await tools.exec_command({
  cmd: "Write-Output 'NESTED_OUTPUT_FORWARDED_MARKER'",
  yield_time_ms: 10000,
  max_output_tokens: 1000
});
text(JSON.stringify({
  exit_code: result.exit_code,
  output: result.output,
  session_id: result.session_id ?? null
}));

Observed:

{"exit_code":0,"output":"NESTED_OUTPUT_FORWARDED_MARKER\r\n","session_id":null}

Impact

In the motivating case, a custom subagent ran a one-shot producer that returns a JSON envelope containing a unique run ID and exact artifact path. The producer apparently completed, but the subagent did not emit the nested tool result. The isolate then ended and the following were all lost:

  • stdout/stderr
  • exit code
  • session ID
  • JSON envelope
  • unique run ID and exact artifact path

The workflow prohibited scanning output directories or rerunning the one-shot producer, so the result became irrecoverable even if artifacts had been generated successfully.

Expected behavior

At least one of the following guardrails would prevent silent evidence loss:

  1. Warn or fail when a functions.exec script awaits a nested tool result but emits no output.
  2. Automatically surface a compact representation of the final awaited tool result when nothing was explicitly emitted.
  3. Provide a lint/runtime warning such as: “Nested tool result was not emitted; call text(), image(), generatedImage(), or store() before the isolate exits.”
  4. Make the successful completion status distinguish “script completed with no emitted output” from “nested command returned empty stdout.”

Actual behavior

The outer call reports successful script completion with an empty Output section, indistinguishable from a nested producer that genuinely returned no output.

Environment

  • Codex Windows desktop app
  • Windows 11
  • Reproduced with PowerShell Write-Output
  • Reproduction does not depend on the original producer, repository, or Unreal Engine

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗