Skip to content

diagnostics: record exact advertised tool-schema bytes in request manifests #1675

Closed

Description

@jhrozek

Summary

Mecatl already records a content-free request.manifest before each provider call. It records the final advertised tool names, prompt component sizes, message count, and encoded message size.

It does not record the total size of the tool schemas actually advertised to the model. That forces incident investigations to reconstruct a request with a mock server just to answer a basic question such as:

Did this turn send 25 tools whose schemas occupied 38 KB?

Add that one exact, content-free measurement and fix the manifest enumeration path so the evidence describes the same tool snapshot that the provider received.

Tracking: #1639

This issue is diagnostic follow-up work only. It does not close or resolve #1639.

Current behavior

Engine.buildRequest constructs the final port.LLMRequest, then compaction may adjust its history suffix. emitRequestManifest emits the existing manifest immediately before LLM.Stream receives that final request.

The current manifest records:

  • provider/model/reasoning-effort identifiers;
  • context window;
  • advertised tool names and advertisement decisions;
  • message count and encoded message bytes; and
  • system/instruction component provenance and sizes.

See engine/agent/loop.go, engine/agent/request_manifest.go, and engine/session/event.go.

Problem

While generating tool-decision evidence, requestToolDecisions calls Tool.Spec() again during catalog enumeration.

A tool specification can refresh live state. The diagnostic path can therefore:

  1. construct a request using one tool specification;
  2. ask the tool for its specification again while preparing evidence; and
  3. record a later state rather than the request snapshot sent to the provider.

It also violates the catalog metadata rule: ordering and filtering must use catalog registration keys, not repeated Tool.Spec() calls.

Proposed behavior

  1. Enumerate catalog tools for manifest decisions using registration-key metadata.

  2. Preserve live Spec() calls only at actual tool-advertisement boundaries.

  3. Add this field to session.RequestManifestPayload:

    advertised_tool_schema_bytes
    
  4. Define it exactly as:

    The sum of len(spec.Schema) for every final req.Tools entry handed to the provider after mode, authority, overlay, progressive-disclosure, and shell-availability filtering.

  5. Expose the number through the existing target-bound InspectSession manifest view.

Privacy and scope

The new field is an integer only. This issue must not add:

  • tool-schema text or descriptions;
  • prompt/message/tool-result content;
  • tool arguments;
  • response content;
  • URLs, headers, cookies, credentials, or provider IDs beyond existing safe fields;
  • hashes/digests of those values;
  • a new CLI/configuration option; or
  • a normal live-client or public event-log projection.

The event remains durable-evidence/debugger-only, consistent with the existing request.manifest contract.

Acceptance criteria

  • Manifest generation adds no Tool.Spec() calls beyond those needed to form the provider request.
  • advertised_tool_schema_bytes equals the schema-byte sum of the final provider-observed req.Tools.
  • Mode, authority, overlay, progressive-disclosure, and shell-less filtering are reflected in the reported total.
  • Existing no-content guarantees still hold with schema/prompt secret canaries.
  • The number is durable and visible through the existing debugger manifest projection, but absent from ordinary client event streams.
  • Engine API compatibility artifacts and changelog classification are updated.

Work classification

Bounded. This extends existing content-free request-manifest evidence without changing its authority, retention, visibility, or raw-content boundary.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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