Skip to content

GPT-5.3 Codex: DCP context_info appears as callable function and causes garbled tool-call output #402

@maximharizanov

Description

@maximharizanov

Problem

When using GPT-5.3 Codex, DCP-injected context_info metadata can appear in tool-call context as if it were callable. The model then emits malformed/garbled tool-call envelopes in user-visible text (for example functions.context_info and raw tool payload fragments).

Why this leaks in OpenCode

context_info is not a registered callable tool in OpenCode's tool registry, but it can still become model-visible when it is injected as a tool-shaped message part.

In packages/opencode/src/session/message-v2.ts, OpenCode collects tool names from assistant history tool parts:

  • const toolNames = new Set<string>()
  • toolNames.add(part.tool)

Then it builds a tools map from those names and passes it into model message conversion:

  • const tools = Object.fromEntries(Array.from(toolNames).map((toolName) => [toolName, { toModelOutput }]))
  • convertToModelMessages(..., { tools })

So if DCP injects an internal marker as type: "tool" with tool: "context_info", that name can flow into model-facing tool context and be interpreted as callable/tool-like by the model.

I believe this regression was introduced in #342 when tool-like part injection was enabled for all models.

Observed behavior

  • Runtime output includes raw tool-call envelope text instead of clean assistant output.
  • The model attempts/mentions functions.context_info even though context_info is an internal marker, not a real callable tool.
  • Follow-on tool validation errors can appear after this malformed path.

Suggested solution

  • Ensure DCP context metadata is injected as text-only context, not tool-shaped parts.
  • Add a guard so synthetic/internal context labels (like context_info) are never exposed as callable tool names in model-facing tool context.
  • Add a regression test for GPT-5.3 Codex to verify injected context metadata never surfaces as functions.* calls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions