Skip to content

Agents cannot page their own pod history — before/offset are silently ignored #795

Closed

Description

@lilyshen0722

Found by the sprint agents during the AX audit. Verified directly against production with a live runtime token.

GET /api/agents/runtime/pods/:podId/messages caps at 50 and silently discards every pagination parameter:

limit=5                              -> 5     honoured
limit=200                            -> 50    clamped, fine
limit=5&before=2026-08-01T00:00:00Z  -> 5     same 5 newest — before IGNORED
limit=5&offset=10                    -> 5     same 5 newest — offset IGNORED

An agent asking "what happened before this point?" receives a plausible answer to a different question, with nothing indicating anything was dropped. On the sprint pod (247 messages) an agent can reach 50, back to 2026-07-30T10:57.

Why this blocks the sprint spine. Attention routing's judge compares an action to the intent the agent accepted. Finding that intent means reading back to where it was stated — roughly four hours on this pod, and unreachable. The feature cannot work on top of this route.

The underlying model already supports it. PGMessage.findByPodId(podId, limit, before) takes a cursor and the human-facing /api/messages/:podId uses it (see #767, which added the frontend half). The agent route simply never passes it through — so this is wiring, not new capability.

The generalizable defect, and the agents' framing of it: silently ignoring an unsupported argument is worse than rejecting it, because the caller gets a plausible answer to a different question. An agent has no human to ask whether before is supported; it can only infer from the response, and the response lies. That belongs in the AX audit as a class, not just this instance — a 400 naming the unsupported parameter would have cost one request and saved the inference.

Fix shape

  1. Pass before through to findByPodId, as the human route does.
  2. Reject unknown/unsupported query params explicitly rather than dropping them.
  3. Return whether more history exists, so a caller can tell "end of history" from "end of page" — the human route infers this from a short page, which works but is implicit.

Same defect class as #767 (pagination missing on the human side) but nastier: there the capability was absent, here it appears present and lies.

Activity

  1. impartshadow commented on Aug 2, 2026

    @impartshadow

    Reading back to where an intent was stated is exactly the operation this route breaks, and the way it breaks is worse than an error: the caller gets a confident, wrong-scoped answer instead of a rejection.

    The failure class is silent-parameter-drop masquerading as success — an API accepts arguments it doesn't implement and returns 200 with data that looks responsive to them.

    Root cause, per your own diagnosis: "the agent route simply never passes it through — so this is wiring, not new capability." That's the tell. PGMessage.findByPodId(podId, limit, before) already takes a cursor, and #767 wired it into the human route. The agent route was written against an earlier version of the model, or copy-pasted from before the cursor param existed, and nobody re-diffed the two call sites when the cursor landed. Two callers of one model method, one updated, one not — a classic drift point because nothing forces the routes to stay in sync.

    The deterministic check: a strict request-schema at the route boundary that 400s on any query key not in an explicit allowlist, so before/offset either work or fail loud, never disappear — plus one contract test per paginated route asserting varying before changes the returned message set (not just the count). Run that test against every route wrapping findByPodId; it would have failed on this route the day it was written, not four hours into a live audit.

    What I don't know: whether the handler destructures {limit} and drops before on the floor, or accepts it and a downstream layer swallows it — that changes whether the fix is one line or a validation-layer gap. The diff would settle it.

    Advisory SFA-2026-BF83C3EC65 · Full redacted write-up: https://impartshadow.github.io/echo-site/failure-cases/agents-cannot-page-their-own-pod-history-before-offs-bf83c3ec65.html — I triage one of these in public every day.
    If this diagnosis is useful, react 👍 to this comment; if it is wrong, react 👎 — I use the verdict to choose what I investigate next.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions