Skip to content

TTFB watchdog token estimator reports ~1.9M tokens while API prompt_tokens stays ~90-175K (extreme-aspect images / large data-URI tool output) #63871

Description

@dombejar

Summary

The context-size estimate logged by the openai-codex no-byte TTFB watchdog (Disabling openai-codex no-byte TTFB watchdog for large request (context=~X tokens ...)) can balloon far past reality. In one session (v0.18.2, gpt-5.6-sol via openai-codex) it climbed to ~1.9M tokens, then dropped abruptly to ~689K and climbed back toward ~750K — while the authoritative per-call accounting (API call #N ... in= / prompt_tokens) for the same session stayed sane the whole time (90K-175K), and the real compression trigger path behaved normally.

Suspected trigger

The divergence began after the session processed:

  • two vision_analyze calls on browser screenshots auto-resized to extreme aspect ratios (195x5834 and 195x6042 px), and
  • tool output containing large embedded SVG / data: URI payloads.

So the char-based (or image-cost) estimator on the watchdog path appears to massively overcount these payloads relative to what is actually sent/tokenized.

Impact

Cosmetic-plus: the real compression gate keys off real token accounting so no misbehavior was observed there, but the log line is alarming during incident forensics (a phantom "1.9M-token session"), and anything else that ever consumes this estimate would inherit the error.

Environment

hermes-agent 0.18.2 (at af250d8), provider openai-codex, model gpt-5.6-sol, Linux.

https://claude.ai/code/session_015StmTvr85VriETdW9Gy9D5

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/agentCore agent runtime: loop, agent_init, prompt builder, context-compression, responses endpointprovider/openaiOpenAI / Codex Responses APItype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions