﻿# A Pydantic object does not prove generated tool arguments passed validation

A practical investigation of a Pydantic object does not prove generated tool arguments passed validation, with explicit observations, control cases and evidence limits.

Author: Retrivium team
Updated: 2026-11-06
Canonical URL: https://retrivium.ai/journal/field-synthetic-pydantic-construct-generated-argument-validation/
Language: en

## The generated-data scenario

A tool-call corpus stores generated arguments as Pydantic model instances. A reviewer sees the expected class and assumes every record passed the declared field rules. That inference fails when the writer uses model_construct. The useful investigation follows the construction path of each candidate, rather than using its eventual Python class as a validation certificate.

## The generation mechanism

Pydantic documents model_construct as construction without validation. Nested dictionaries are not automatically converted into nested model objects by that path. Defaults can still populate fields, making an incomplete candidate look well formed. Even extra fields under an extra-forbid model do not produce the validation error expected from the ordinary validation path; construction ignores them.

## Define the dataset contract

Define separate provenance for generated bytes, parsed argument values, validation results and the admitted representation. A field containing a numeric-looking string must not silently become evidence that the generator emitted the required numeric type. If coercion is permitted, retain that transformation explicitly. A rejected extra field must remain observable even when a later representation omits it.

## A step-by-step protocol

First freeze the schema and the admission API. Prepare a valid candidate, a wrong-type candidate, an invalid nested value and an unexpected field. Submit each through the actual admission path and record its decision. Separately construct trusted objects from the same inputs as a control. Compare field contents and errors, without invoking the tools represented by those arguments.

## Evidence required for acceptance

Acceptance requires a trace connecting each admitted example to a successful validation result under the recorded schema and settings. Preserve rejected originals, transformations and nested-object types. The control should demonstrate that construction and validation are distinguishable operations. A serialized object alone cannot establish this history, because both paths may emit apparently ordinary dictionaries afterward.

## Failure cases and limits

Trusted construction can be appropriate after an earlier verified boundary; the problem is losing evidence of that boundary. Validation also checks only implemented rules, not whether a tool request is safe, authorized or factually appropriate. Treat this as a data-admission review, not a claim that changing constructors improves model quality or proves downstream tool execution correct.

## Primary references and related reading

Validate generated arguments at admission; model_construct deliberately trusts its input. [Pydantic constructing models without validation](https://pydantic.dev/docs/validation/latest/concepts/models/); [Pydantic BaseModel trusted-data construction API](https://pydantic.dev/docs/validation/latest/api/pydantic/base_model/).

The proposed investigation of pydantic construct generated argument validation is a proposed dataset-contract review; no production dataset was generated or evaluated. Related reading: [AgentCompat: which recorded tool calls survive a schema migration?](/journal/agentcompat-tool-schema-replay-baseline-valid-weighted-denominator/); [Provider structured output: testing JSON and schema conformance separately](/journal/provider-structured-output-conformance-tests/).
