Skip to content

fix(trpc): default agent to 'claude' in createAutomationSchema for SDK <alpha.10 compat#4552

Closed
sazabi[bot] wants to merge 1 commit into
mainfrom
fix/automation-create-agent-default-compat
Closed

fix(trpc): default agent to 'claude' in createAutomationSchema for SDK <alpha.10 compat#4552
sazabi[bot] wants to merge 1 commit into
mainfrom
fix/automation-create-agent-default-compat

Conversation

@sazabi
Copy link
Copy Markdown
Contributor

@sazabi sazabi Bot commented May 14, 2026

Problem

SDK <alpha.10 and callers predating PR #4481 omit the agent field (previously agentConfig) from automation.create requests. Since #4481 deployed the agent text not null DB column and strict Zod schema, these callers receive a BAD_REQUEST ZodError: Invalid input: expected string, received undefined on the agent path.

17 errors observed in production since 2026-05-13 12:32 UTC.

The error pattern:

❌ tRPC error on automation.create: Error [TRPCError]: [{ "expected": "string", "code": "invalid_type", "path": ["agent"], "message": "Invalid input: expected string, received undefined" }]

Fix

Add .default("claude") to the agent field in createAutomationSchema. This makes the field optional on the wire (matching SDK <alpha.10 / CLI <0.2.16 behaviour) while the stored value remains a non-null string — identical to the pre-rename implicit default.

No changes to the DB schema or any other callers.

Testing

Relates to #4481.


Summary by cubic

Default agent to "claude" in createAutomationSchema to restore compatibility with older clients that omit the field. This prevents Zod BAD_REQUEST errors on automation.create while keeping the DB value non-null.

  • Bug Fixes
    • Set agent default via agentSchema.default("claude").
    • Stops 17 production errors from SDK <alpha.10 / older CLI.
    • No impact on current SDK/CLI; no DB changes.

Written for commit d1199a9. Summary will update on new commits.

…K <alpha.10 compat

SDK <alpha.10 and any caller predating PR #4481 omit the `agent` field
(previously `agentConfig`) and receive a ZodError BAD_REQUEST.  Adding
`.default('claude')` makes the field optional-on-wire while keeping it
required in the DB — matching the pre-rename behaviour where claude was
effectively the implicit default.

17 BAD_REQUEST errors observed in production since 2026-05-13 12:32 UTC.

Relates to #4481.
@capy-ai
Copy link
Copy Markdown

capy-ai Bot commented May 14, 2026

Capy auto-review is paused for this organization because the monthly auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 14, 2026

Greptile Summary

This PR applies a targeted backwards-compatibility fix for the automation.create tRPC endpoint, restoring tolerance for callers on SDK <alpha.10 or CLI <0.2.16 that omit the agent field after the agentConfig→agent rename landed in #4481.

  • Adds .default(\"claude\") to agentSchema in createAutomationSchema, making agent optional on the wire while the persisted DB column value remains a non-null string.
  • No DB schema changes, no other callers affected; the \"claude\" default matches the implicit pre-rename behaviour.

Confidence Score: 5/5

Safe to merge — single-field schema change with no DB impact and a valid, bounded default value.

The change is a one-line addition of .default("claude") to a Zod string field. The default satisfies the existing min(1).max(200) constraints, the persisted column stays non-null, and no other callers or schemas are touched. The fix directly matches the error pattern observed in production logs.

No files require special attention.

Important Files Changed

Filename Overview
packages/trpc/src/router/automation/schema.ts Adds .default("claude") to the agent field in createAutomationSchema so SDK <alpha.10 / CLI <0.2.16 callers that omit the field are silently defaulted instead of receiving a Zod validation error.

Sequence Diagram

sequenceDiagram
    participant OldCaller as SDK <alpha.10 / CLI <0.2.16
    participant NewCaller as SDK ≥alpha.10 / CLI ≥0.2.16
    participant tRPC as tRPC automation.create
    participant Zod as createAutomationSchema
    participant DB as Database

    OldCaller->>tRPC: "{ name, prompt } (agent: undefined)"
    tRPC->>Zod: "parse({ name, prompt })"
    Note over Zod: agent: agentSchema.default("claude")<br/>undefined → "claude"
    Zod-->>tRPC: "{ name, prompt, agent: "claude" }"
    tRPC->>DB: "INSERT agent = "claude""

    NewCaller->>tRPC: "{ name, prompt, agent: "claude-opus-4" }"
    tRPC->>Zod: "parse({ name, prompt, agent: "claude-opus-4" })"
    Zod-->>tRPC: "{ name, prompt, agent: "claude-opus-4" }"
    tRPC->>DB: "INSERT agent = "claude-opus-4""
Loading

Reviews (1): Last reviewed commit: "fix(trpc): default agent to 'claude' in ..." | Re-trigger Greptile

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 14, 2026

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch

Thank you for your contribution! 🎉

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