Tools, Functions, and Agentic Workflows
Integrate function calling and tools, design planner–executor patterns, and manage errors, scopes, and observability.
Content
Parameter Schema Design
Versions:
Watch & Learn
AI-discovered learning video
Sign in to watch the learning video for this topic.
Parameter Schema Design — The Glue Between Agents and Safe, Predictable Actions
"A function without a schema is like a vending machine without labels — you might get a snack, you might summon a greased raccoon."
You already know how function calling patterns let models reach out and do things, and how audit trails and transparency keep us honest. Parameter schema design is the middle manager that makes sure those functions actually get the right stuff, safely, and with a paper trail.
What is a parameter schema (in plain chaos-free terms)?
Parameter schema = a formal description of the shape, types, constraints, and meaning of the inputs a tool/function expects. Think of it as the instruction card taped to the vending machine: which coin goes where, which button yields which candy, and what to do if the machine detects a jam.
Why it matters:
- Predictability: Agents can prepare data in exactly the format the function expects (fewer runtime errors).
- Safety & Privacy: You can label, validate, and sanitize fields (e.g., PII) before anything is executed or logged.
- Accountability: Schemas enable consistent audit logs and provenance when combined with your traceability practices.
This builds directly on function calling patterns (we're specifying how functions should be called) and on the audit/transparency rules (we can require provenance fields and redactable tokens right in the schema).
Core components of a good parameter schema
- Types: string, number, boolean, object, array, integer, null
- Required vs optional: explicitness avoids surprises
- Formats/constraints: regex, min/max, enum, date-time, uri
- Descriptions: human-friendly meanings — crucial for model interpretation
- Examples: for both developer and model grounding
- Metadata: version, stability, privacy labels, deprecation notice
Example (JSON Schema-like) — CreateInvoice
{
"title": "create_invoice",
"version": "2024-03-01",
"type": "object",
"required": ["amount_cents", "currency", "customer_id"],
"properties": {
"amount_cents": { "type": "integer", "minimum": 1, "description": "Amount in cents to avoid floating point shenanigans" },
"currency": { "type": "string", "enum": ["USD", "EUR", "GBP"], "description": "ISO currency code" },
"customer_id": { "type": "string" },
"due_date": { "type": "string", "format": "date" },
"priority": { "type": "string", "enum": ["normal", "high"], "default": "normal" },
"notify_customer": { "type": "boolean", "default": true },
"metadata": { "type": "object" },
"privacy_label": {
"type": "string",
"enum": ["public", "sensitive", "pii"],
"description": "Controls downstream handling & logging. Use 'pii' only when strictly necessary."
}
}
}
Notes:
- Use integers for money (avoid floats).
- Add a privacy_label or data_class field so agents and pipelines can apply appropriate redaction or routing.
Schema design patterns for agentic workflows
Agents don't just call functions — they reason about which function to call and how to fill parameters. Here are patterns that make that reliable.
Slot-filling + Validation
- Agent extracts slots from user intent, maps to schema keys, then runs a validator. If validation fails, ask a clarifying question instead of firing the function.
Schema-driven tool selection
- Match user intent to tools by comparing what schemas can be satisfied. Prefer tools whose required fields are present and whose privacy constraints match the context.
Redaction and Routing based on metadata
- If privacy_label == "pii", send the call through a hardened path — minimal logs, encryption, or human review.
Progressive disclosure
- Start with minimal required fields; only request sensitive optional data when necessary and justified.
Fallbacks and graceful degradation
- If a schema constraint cannot be satisfied (e.g., unsupported currency), agent should offer alternatives rather than crashing.
Pseudo-flow:
User -> Agent: intent
Agent -> Map intent to schema
Agent -> Fill slots
Agent -> Validate against schema
If valid: sanitize -> attach provenance -> call function
If invalid: ask clarifying Q or propose fallback
Safety, auditability, and transparency baked into schemas
We previously covered audit trails and transparency. Parameter schemas are where you can require audit fields and privacy metadata consistently.
- Add optional/required fields for: request_id, user_id (or hashed identifier), consent_flags, timestamp
- Add a privacy_label and retention_policy metadata so downstream systems can automatically apply logging/redaction rules
- Include a schema version and change log entry so audits can explain why an older agent invocation used a previous schema
Quick example snippet (audit-related fields):
"properties": {
"request_id": { "type": "string", "description": "GUID for traceability" },
"caller": { "type": "string", "description": "User or service ID (hash recommended)" },
"consent": { "type": "boolean", "description": "Was user consent obtained for this operation?" }
}
Caveat: don't use schemas to shove raw PII into every log. Use labels and hashed identifiers.
Testing, versioning, and governance
- Schema fuzzing: generate lots of valid/invalid inputs to ensure your tool doesn't misbehave when fed edge cases.
- Backward compatibility rules: bump minor version for additive, major for breaking changes. Agents should be able to request the schema version.
- Governance: treat schema changes like API changes — require PRs, review, and signed-off changelogs.
- Docs-as-code: commit schemas with human-readable docs and examples.
Table: Quick constraint checklist
| Constraint type | Purpose | Example |
|---|---|---|
| enum | limit expected values | currency in [USD, EUR] |
| regex/format | enforce structure | email/uri/date |
| minimum/maximum | guard numeric ranges | amount_cents >= 1 |
| required | prevent missing critical inputs | customer_id required |
| privacy_label | drive handling policy | pii, sensitive, public |
Common pitfalls (and how to dodge them)
- Overly permissive schemas: "string" for everything is lazy and lethal. Be specific.
- Overly strict schemas: never make life impossible for agents or users; allow sane defaults.
- Hiding privacy policies: schema-level labels are better than hoping developers remember to redact.
- No versioning: schema drift will make your audit trail a horror movie.
Quick checklist before you ship a schema
- Types and required fields are explicit
- Descriptions and examples included for each field
- Privacy metadata (labels/consent) present for sensitive fields
- Validation rules for obvious edge cases (e.g., currency, dates)
- Schema version and changelog entry
- Tests cover valid/invalid/fuzz cases
- Agent behavior on validation errors is defined
Final mic-drop: why schema design actually matters
Parameter schemas are where correctness, safety, and accountability meet. They’re not just boring bureaucracy — they're the contract between your intelligent agent and the real world. A well-crafted schema prevents accidents, protects user data, and makes audits readable instead of rage-inducing detective work.
So design your schemas like you design safety-critical systems: with clarity, with constraints, and with an eye on who will have to read the logs at 3 a.m. when something goes sideways.
"When in doubt: validate, label, and log. Your future auditor will worship you."
Comments (0)
Please sign in to leave a comment.
No comments yet. Be the first to comment!