Skip to content

zUsageUpdate schema rejects null for 'used' field #91

@kagura-agent

Description

@kagura-agent

Problem

zUsageUpdate in schema/zod.gen.js defines:

export const zUsageUpdate = z.object({
    _meta: z.record(z.string(), z.unknown()).nullish(),
    cost: zCost.nullish(),
    size: z.number(),
    used: z.number(),  // <-- does not accept null
});

But @zed-industries/claude-agent-acp@0.21.0 sends used: null in session/update notifications (e.g. at the start of a session before any tokens are used).

This causes the client-side notification handler to throw:

Error handling notification {
  method: 'session/update',
  params: { update: { sessionUpdate: 'usage_update', used: null, size: 200000, cost: {...} } }
} { code: -32602, message: 'Invalid params', data: { _errors: ['Invalid input: expected object, received undefined', ...] } }

Suggested Fix

Change used to accept null/undefined, consistent with other optional fields:

- used: z.number(),
+ used: z.number().nullish(),

Environment

  • @agentclientprotocol/sdk@0.15.0
  • @zed-industries/claude-agent-acp@0.21.0
  • acpx@0.1.16

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