Skip to content

feat: normalize provider tool specifications - #119

Draft
hallerite wants to merge 1 commit into
codex/freeze-golden-corpusfrom
codex/normalize-tool-specs
Draft

feat: normalize provider tool specifications#119
hallerite wants to merge 1 commit into
codex/freeze-golden-corpusfrom
codex/normalize-tool-specs

Conversation

@hallerite

@hallerite hallerite commented Aug 6, 2026

Copy link
Copy Markdown
Member

Summary

  • add one canonical normalization boundary for client-executed JSON-schema function tools
  • accept legacy/verifiers, OpenAI Chat Completions, OpenAI Responses, Anthropic, MCP, Gemini-compatible, and Pydantic-style inputs
  • integrate normalization across every renderer and schema-aware response parser
  • reject hosted, custom-text, namespace, shell, computer, and other non-function protocols with an explicit capability error
  • preserve the existing Chat-style rendered token contract and legacy ToolSpec(...) construction
  • document the supported provider shapes and export typed public helpers

Why

Equivalent function tools use different wire schemas across providers. Renderers previously handled a mixture of flat and Chat-style definitions locally, so Responses, Anthropic, and MCP inputs could be rendered inconsistently or lose schema information during parsing. Normalizing once at the boundary keeps model-specific renderers provider-agnostic and makes unsupported execution protocols fail loudly instead of being silently misrepresented.

Stack

This is stacked on #118 (codex/freeze-golden-corpus). The frozen golden corpus is unchanged by this PR.

Validation

  • uv run ruff check .
  • uv run ty check renderers (exit 0; existing advisory diagnostics only)
  • offline suite: 130 passed
  • pinned text-model suite: 2,586 passed, 110 skipped, 1 expected failure
  • pinned multimodal suite: 73 passed, 17 skipped
  • focused provider-shape parity: 105 passed
  • normalization and actual OpenAI SDK inputs: 41 passed
  • uv build

Note

Normalize provider tool specifications across all renderers

  • Adds a new renderers/tools.py module that defines normalize_tool_spec() / normalize_tool_specs(), canonical types (CanonicalToolSpec, FunctionSpec, etc.), and error types (ToolSpecError, UnsupportedToolSpecError).
  • Applies normalize_tool_specs() at the start of every renderer's render() method and in the _build_param_type_index / _extract_tool_names parsing helpers, replacing ad hoc envelope-unwrapping.
  • Accepts tool shapes from OpenAI Chat Completions, OpenAI Responses API, Anthropic, MCP, and Pydantic-style model objects; normalizes all to a single canonical envelope.
  • Risk: renderers now raise ToolSpecError or UnsupportedToolSpecError for invalid or unsupported tool protocols, where they previously silently accepted arbitrary inputs.

Macroscope summarized 2b19413.

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.

1 participant