Skip to content

Gateway agent calls fail: 'Invalid value: custom' for tools[].type #85009

Closed as not planned

Description

@forbiddenlink

Summary

Cron jobs failing because gateway passes tools[].type: "custom" to Anthropic Messages API → 400.

Repro

  • Version: openclaw 2026.5.19 (a185ca2)
  • Platform: macOS 26.5 arm64, node 22.22.2
  • Setup: 2 agents (main + crcbot), 11 cron jobs targeting Anthropic + OpenAI

Error

{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "code": "unknown_parameter",
    "message": "Invalid value: 'custom'",
    "param": "tools"
  },
  "status": 400
}

Source

grep -r 'type: "custom"' dist/ shows the literal in src-BSuxs9xi.js + schemas-Bmna8ihM.js (3 occurrences). Anthropic Messages API doesn't accept tools[].type: 'custom' as a valid tool type. Valid: omit type for user-defined tools, or use computer_20241022/text_editor_20241022/bash_20241022 for builtin tools.

Impact

All cron jobs w/ tool-calling agents fail silently. openclaw secrets audit clean, openclaw status clean, but cron list shows 9/11 jobs in error state.

Workaround

openclaw cron disable <id> for affected jobs.

Activity

  1. clawsweeper commented on May 21, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve.

    Workflow note: Future ClawSweeper reviews update this same comment in place.

    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

    Summary
    Keep open: the report has concrete release/provider error evidence, and current main still has a source path where a custom Anthropic session stream can bypass OpenClaw's Anthropic tool-shaping transport.

    Reproducibility: yes. at source level: the issue supplies the shipped provider 400 and packaged payload evidence, and current main still has a custom-session stream path that can bypass OpenClaw's Anthropic tool converter. I did not execute a live Anthropic cron job in this read-only review.

    Next step
    This is a narrow provider/gateway compatibility bug with concrete release evidence, clear current-main source path, and focused validation.

    Review details

    Best possible solution:

    Keep OpenClaw's policy-owned tool inventory intact, but make every Anthropic Messages run path that can carry customTools use OpenClaw's Anthropic tool wire shape or an equivalent provider-owned adapter.

    Do we have a high-confidence way to reproduce the issue?

    Yes, at source level: the issue supplies the shipped provider 400 and packaged payload evidence, and current main still has a custom-session stream path that can bypass OpenClaw's Anthropic tool converter. I did not execute a live Anthropic cron job in this read-only review.

    Is this the best way to solve the issue?

    Yes: the best fix is at the provider/embedded-runner transport boundary, not in cron or secrets, so Anthropic requests use the accepted tool schema while OpenClaw policy and sandbox tool registration remain unchanged.

    Label changes:

    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.
    • add clawsweeper:queueable-fix: Current issue advisory state selects this label.
    • add clawsweeper:fix-shape-clear: Current issue advisory state selects this label.
    • remove clawsweeper:needs-live-repro: Current issue advisory state no longer selects this label.
    • remove issue-rating: 🐚 platinum hermit: Current issue advisory state no longer selects this label.

    Label justifications:

    • P1: The issue reports released cron jobs failing now for tool-using Anthropic agents with clean status/audit output.
    • impact:message-loss: Failed scheduled agent runs can suppress expected cron replies or task output.
    • impact:auth-provider: The failure is in provider-specific Anthropic Messages request shaping and stream routing.

    Acceptance criteria:

    • node scripts/run-vitest.mjs src/agents/pi-embedded-runner/stream-resolution.test.ts
    • node scripts/run-vitest.mjs src/agents/anthropic-transport-stream.test.ts
    • node scripts/run-vitest.mjs src/agents/pi-embedded-runner.splitsdktools.test.ts
    • Run live or Crabbox Anthropic cron/gateway proof if credentials are available; otherwise document the missing live credential and include payload-shape proof.

    What I checked:

    • Reported released failure: Live issue data reports openclaw v2026.5.19 returning Anthropic 400 Invalid value: 'custom' for param: tools, with 9 of 11 cron jobs in error state and clean status/audit output.
    • Release tag provenance: The reported release SHA is tagged v2026.5.19; the issue targets shipped behavior, not only unreleased main. (a185ca283a74)
    • Current tool ownership path: Current main still routes OpenClaw-managed tools through Pi customTools, which preserves policy filtering but can also reach Pi/provider serialization if the OpenClaw transport is bypassed. (src/agents/pi-embedded-runner/tool-split.ts:5, 9f2c0a80b40f)
    • Current custom-stream bypass: resolveEmbeddedAgentStreamFn only forces boundary-aware transport for default stream functions or already-resolved runtime keys; otherwise it returns the session's custom stream function. (src/agents/pi-embedded-runner/stream-resolution.ts:167, 9f2c0a80b40f)
    • Existing test documents the remaining bypass: The focused test suite still expects custom session streams to be classified as session-custom, while runtime-auth custom streams use the boundary-aware Anthropic transport. (src/agents/pi-embedded-runner/stream-resolution.test.ts:91, 9f2c0a80b40f)
    • Anthropic transport has the accepted tool shape: OpenClaw's direct Anthropic converter emits name, optional description, and input_schema fields for tools, with no top-level type: "custom". (src/agents/anthropic-transport-stream.ts:464, 9f2c0a80b40f)

    Likely related people:

    • Peter Steinberger: Git blame shows the current stream-resolution, tool-split, and Anthropic converter lines were introduced in commit 2fd02c2, and shortlog shows he is the heaviest contributor in the sampled affected files. (role: recent area contributor; confidence: high; commits: 2fd02c206064, 02182d5a3031; files: src/agents/pi-embedded-runner/stream-resolution.ts, src/agents/pi-embedded-runner/tool-split.ts, src/agents/anthropic-transport-stream.ts)
    • Vincent Koc: Recent current-main history includes adjacent embedded-runner attempt work and the current HEAD commit, so he is a useful routing candidate for recent agent-runtime interactions. (role: recent adjacent contributor; confidence: medium; commits: 2bb00f6726d4, 9f2c0a80b40f; files: src/agents/pi-embedded-runner/run/attempt.ts)

    Remaining risk / open question:

    • I did not run a live Anthropic cron request in this read-only review, so the provider failure is source-reproducible rather than directly reproduced against Anthropic.
    • Current main already has a correct direct Anthropic converter, so the fix should confirm why the cron/custom-session path falls through before changing cron behavior.

    Codex review notes: model gpt-5.5, reasoning high; reviewed against 9f2c0a80b40f.

  2. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    and removed
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    on May 21, 2026
  3. JulyanXu commented on May 22, 2026

    @JulyanXu
    Contributor

    Source-verified. The issue is that OpenClaw's tool schema includes type: "custom" for user-defined tools, but Anthropic's Messages API doesn't accept this value.

    Valid Anthropic tool types: Omit type entirely for custom tools, or use one of the built-in types (computer_20241022, text_editor_20241022, bash_20241022). Anthropic's API treats tools without a type field as custom tools by default.

    Root cause: The tool schema serialization code likely adds type: "custom" to differentiate custom tools from built-in ones in OpenClaw's internal representation, but this field shouldn't be forwarded to providers that don't support it.

    Fix location: The provider adapter layer (where tool schemas are transformed before sending to each LLM provider) should strip type: "custom" when targeting Anthropic, or more generally, strip any type field value that isn't in the provider's accepted set.

    This should be a provider-level normalization, not a global schema change — OpenClaw may legitimately use type: "custom" internally. The Anthropic provider adapter should filter it before the API call.

    Pattern for other providers: OpenAI accepts type: "function" for custom tools. Google accepts functionDeclarations. Each provider adapter should handle the type field normalization independently.

  4. steipete commented on Jun 14, 2026

    @steipete
    Contributor

    Closing as misattributed after reproducing the exact v2026.5.19 dependency path.

    The release pinned @earendil-works/pi-ai@0.75.1. I installed that exact package and captured its pre-request Anthropic payload with a custom tool. The tool keys were:

    cache_control, description, eager_input_streaming, input_schema, name
    

    The tool had no top-level type field (Object.hasOwn(tool, "type") === false). Source inspection confirms Pi's shipped convertTools emitted only Anthropic's name / description / input_schema shape plus optional Anthropic fields. OpenClaw's own transport in the same release also omitted type: "custom". The type: "custom" literals found by grepping bundled files came from unrelated schemas/internal records and do not prove that value was sent in an Anthropic request.

    The reported error shape includes code: "unknown_parameter" and param: "tools", so it may have originated from an OpenAI-compatible gateway or another provider route among the mixed Anthropic/OpenAI cron jobs. Current main keeps provider-owned tool serializers and has explicit compatibility shaping for OpenAI-compatible Anthropic-family endpoints.

    If this still occurs, please open a new issue (or ask to reopen) with the exact provider id, model ref, redacted base URL/endpoint family, one failing cron model selection, and a redacted before_provider_request payload. That evidence would identify the actual adapter without redirecting all official Anthropic/custom streams.

  5. locked as resolved and limited conversation to collaborators on Jun 25, 2026
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

    P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions