Skip to content

fix(acp): tolerate missing token count for handled Codex commands #4079

Description

@neubig

Summary

An ACP conversation can fail when codex-acp handles an unknown slash command such as /codereview-roasted.

Reproduction

  1. Start an ACPAgent conversation backed by @agentclientprotocol/codex-acp.
  2. Send an unsupported slash command, for example /codereview-roasted this PR.
  3. The adapter handles the command locally and returns a successful session/prompt response without a model turn or usage update.

Actual behavior

codex-acp returns usage: null and _meta.quota.token_count: null. ACPAgent._extract_token_usage() treats the null token count as a mapping and raises:

'NoneType' object has no attribute 'get'

The generic ACP turn-error path then emits ACPPromptError and marks the entire conversation ERROR, so it cannot continue normally.

Expected behavior

A successful handled command with no usage information should record zero token usage and complete the turn. Unknown commands should show the adapter-provided response without poisoning the conversation.

Proposed fix

Normalize nullable quota and token_count values to empty mappings before reading counters, with a regression test for {"quota": null} / {"quota": {"token_count": null}}.

Activity

  1. neubig commented on Jul 10, 2026

    @neubig
    MemberAuthor

    Closing as already fixed by #4056. That merged change normalizes nullable ACP quota and token_count metadata, including the exact {"quota": {"token_count": null}} response returned when codex-acp handles an unknown slash command.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions