Skip to content

fix(runtime): preserve Pi tool schemas and multimodal input across Pi and Codex - #1243

Merged
yaozheng-fang merged 4 commits into
mainfrom
fix/piagent-request-compatibility
Dec 2, 2026
Merged

yaozheng-fang merged 4 commits into
mainfrom
fix/piagent-request-compatibility

Conversation

@yaozheng-fang

@yaozheng-fang yaozheng-fang commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

What failed

An ADK tool declared an object with properties and a root-level oneOf. The Pi extension rebuilt it as a TypeBox union, retaining the alternatives as anyOf and discarding the object type and its other constraints. A model provider rejected the entire tool list before the first tool call. Pi reported the provider error on message_end, so the caller saw an incomplete response instead of the HTTP 400.

Changes

  • Register the original JSON Schema with Pi, including sibling constraints, nested references, and additional properties.

  • Carry inline user images through Pi’s context bridge in the original order, including image-only turns.

  • Surface the terminal provider error, redact the configured model key, and let announced retries finish before reporting failure. A failed partial response is never promoted to a final answer.

  • Sample inline animated GIF and MP4/MOV/WebM into ordered PNG frames for both Pi and Codex, including visual-only prompts. Keep static images on their original path and preserve the original file for Codex.

  • Keep genuine MCP image results typed on the Codex MCP transport and on the Responses shim, including the next tool round. Regular text tools retain the existing representation.

The Codex extra installs PyAV (locked to 16.1.0). Pi-only users who need video install veadk-python[piagent]. Text, still images and animated GIFs work without this extra. The default SDK and offline Studio release omit the video decoder. The runtime guides in both languages describe sampling up to eight visual frames including the endpoints. Audio transcription is outside the visual sampling path.

Verification

  • Installed a built wheel in a clean environment with the downstream Studio Harness dependency pins. Dependency consistency passed. The real Pi binary and a live provider completed a round trip with the original 23 tool declarations, executed a harmless test tool, and returned its unique result.
  • With a local provider fixture and the real Pi binary, checked all 23 tool schemas field-for-field, compared PNG bytes for image-only and mixed input, and confirmed that a provider 400 reached the caller with its credential redacted. Exercised both valid branches of the original sandbox schema and confirmed conflicting arguments were rejected before execution.
  • All 6 real-binary Pi smoke cases passed (live-provider and controlled-provider cases). The Python 3.10 packaged Pi regression suite passed 90 tests. The downstream Studio Harness suite passed all 400 tests.
  • Both language versions of the docs passed type checking and static export. Repository-wide pre-commit hooks passed, including Ruff and secret scanning.
  • The original Pi-only revision passed 9712 Python 3.12 tests. Verification for the follow-up revision is recorded below.

Combined skill, environment, MCP, and hook tests

Reinstalled the PR wheel with the downstream Harness pins. Tests used real Pi and Codex binaries, a live model, a Streamable HTTP MCP server, the Studio skill registry and environment tools, and a small Python receipt program in an isolated working directory. The Hook fixture spoke the Studio health, catalog, and invocation HTTP protocol over a local Unix socket. The environment adapter ran locally. No production deployment or public Hook endpoint was involved.

  • Two concurrent Pi sessions and a Codex control loaded an environment skill. Its instruction selected the MCP record, the before-tool hook changed the record sent to the real MCP service, and the after-tool hook added a receipt. All three final answers contained the output of their own environment process and the expected model and tool hook markers. The sessions did not exchange receipts.
  • One Pi session received a temporary MCP error and recovered in exactly two calls. The other Pi session and Codex made one call each.
  • A before-tool Hook veto produced the configured denial reason in both Pi and Codex. The MCP server recorded zero tool calls and the environment script never ran.
  • Separately injected a provider 400 and an exception from a tool executor using a controlled model endpoint and the real Pi binary. The model-error and tool-error Hooks each ran exactly once and their recovery results reached the caller. The provider error passed to the Hook retained its reason and redacted the sample credential.
  • In a second turn, each of the three sessions returned its own previous environment and Hook receipts without repeating any tool call.

Multimodal regression and package verification

The earlier implementation preserved only the first animated GIF frame, omitted video images and flattened an MCP PNG into text on Codex. A direct provider control returned both visual codes. The following checks used an installed wheel, actual Pi and Codex processes and a live vision provider. Random reference numbers were present in the media and absent from filenames and prompts.

  • The initial 26/26 runtime/case combinations returned the expected values. Both runtimes read two different codes in time order for animated GIF, MP4, MOV and WebM. Controls covered PNG-only, JPEG, WebP, still GIF, three images in attachment order, looking back at an unread part of a previous image, nine downstream-extracted document formats and a mixed image + document turn.
  • Each runtime called the actual stdio MCP image tool once and returned the exact code from its PNG. Codex passed both the default transport and the forced Responses shim. The permanent shim test also checks typed image output and absence of duplicate execution when the next request replays tool history.
  • The original 23-tool Pi provider round trip, all six live Pi smoke tests, skill lookup + real HTTP MCP + environment execution and Hook receipts passed. A second turn used the original session receipts without repeating tool execution. Blocking hooks made zero MCP calls. Model- and tool-error hooks returned their tested fallbacks.
  • Built and installed the wheel with the downstream pins and checked dependency consistency. Python 3.10 packaged Pi tests passed 93 cases. Both language versions of the docs passed type checks and static export. Repository-wide pre-commit passed.
  • A clip longer than the sample budget is represented by up to eight selected frames. The models receive visual frames without an audio track. Standalone WAV/MP3 transcription was not added.

The full Python 3.12 regression run on this revision completed with 9717 passed, 85 skipped, 4 xfailed, 179 warnings, 6 subtests passed. The separately enabled local Codex smoke suite completed with 32 passed and 2 skipped (optional database services).

Packaging and repeated live checks

An intermediate build bundled the 39.3 MiB decoder wheel with the base SDK. Its 299,493,961-byte offline Studio zip failed the existing 256 MiB customer-update limit. The final change places the decoder in the runtime extras. Frozen base dependencies are otherwise identical. Install tests from the clean wheel confirmed that base imports without PyAV and each runtime extra installs the decoder. The final bundle is 258,550,566 bytes (246.6 MiB). The unchanged 256 MiB limit and simulated customer upgrade/startup passed. Release verification

Both runtimes again returned both visual codes in order for GIF, MP4, MOV and WebM on the clean wheel. One additional mixed PNG + extracted PDF repeat returned only the image code; the original mixed prompt gave variable results across runs. A request capture for each engine confirmed the exact PNG plus the PDF code in the text, and both returned both values when asked specifically to read the attached PDF text. This is a limitation of recognition on that prompt.

@yaozheng-fang yaozheng-fang changed the title fix(piagent): preserve tool schemas, image inputs, and provider errors fix(runtime): preserve Pi tool schemas and multimodal input across Pi and Codex Dec 2, 2026
@yaozheng-fang
yaozheng-fang merged commit ea78f82 into main Dec 2, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants