Skip to content

REST engine: give tools access to response headers (Link pagination, rate limit info) #557

Description

@keysersoft

Came up while reviewing the Sentry adapter in #551 and it applies to GitHub, GitLab, Shopify and most APIs that paginate with a Link header or return rate limit info in headers.

Today the REST engine returns only the response body to the tool. A list tool can accept a cursor parameter, but the model never sees the next cursor because it lives in Link: <...&cursor=xyz>; rel="next". So every list tool is effectively one page, and adapter authors either document the limit (as #551 does) or invent workarounds.

What I'd like:

  • an opt in per tool, something like "exposeHeaders": ["link", "x-ratelimit-remaining"] in the endpoint mapping, so we don't bloat every response
  • the selected headers appended to the tool result, probably as a small _headers object in the structured content and a one line note in the text content
  • for the Link case specifically, parse rel="next" into a nextCursor (or nextUrl) field so the model can call the same tool again without string surgery

Things to keep in mind: response mapping should still apply to the body only, and the audit log shouldn't grow because of this, headers are small but multiply by 22k tools quickly if we log them all.

If someone wants to pick this up, packages/backend/src/connectors/engines/rest.engine.ts is where the response gets shaped, and nominatim.live.spec.ts shows how we do live tests behind a flag.

Activity

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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions