Repository navigation
fix(agent-server): refuse more than 99 batch-get ids with a 422 - #5795
Merged
Merged
Conversation
GET /api/conversations enforced its 99-id limit with a bare assert, so 100 or more ids became a 500 with an empty exception. Declare the limit as Query(max_length=99) instead: the request is a 422 naming the limit, the service is not called, and OpenAPI shows maxItems: 99. Drop the known-bug marker from the F04.batch-get-limit map bullet. Fixes #5790 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014MKndVj7XWvRQmvW9w2bDg
1 of 11 tasks
Contributor
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
Contributor
enyst
marked this pull request as ready for review
October 13, 2026 23:32
all-hands-bot
approved these changes
Oct 13, 2026
all-hands-bot
left a comment
Collaborator
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Review: PR #5795 — refuse more than 99 batch-get ids with a 422
Scope
Agent-server REST API change (the canonical API owned by this repository). It replaces an assert-based batch-size guard with a declared FastAPI/Pydantic query constraint, matching the authoritative pattern already used for the search limit (Query(gt=0, le=100), #5114). In scope; no cross-repository ownership issue.
What I verified on the current head (f2ac77c0)
- Runtime behavior.
ids: Annotated[list[UUID], Query(max_length=99)]turns 100 ids into a FastAPI 422 ("List should have at most 99 items") before the handler body runs, soconversation_service.batch_get_conversationsis not called. The newmock_conversation_service.batch_get_conversations.assert_not_called()intest_batch_get_conversations_too_many_idsconfirms nothing reaches the service. - 99 ids still work. The same test asserts
200with[None] * 99, and the router tests I ran pass (109 passedfortests/agent_server/test_conversation_router.py tests/agent_server/test_openapi_contract.py). - OpenAPI declaration.
test_batch_get_conversations_openapi_declares_id_limitassertsmaxItems == 99on theidsparameter, so the bound is in the published schema, not only enforced. This matches the PR's OpenAPI contract diff. - Assert removal. The message-less
AssertionErrorthat produced500 {"detail": "Internal Server Error", "exception": ""}is gone, and the check no longer disappears underpython -O. - CI. All check runs on
f2ac77c0aresuccess/skipped; no failing or pending required check. - Issue #5790 is open with
bug/priority:low/ready-for-dev; every acceptance criterion it lists (422 naming the limit, service not invoked, 99-id 200, declared schema bound, updated router test,# bugmarker removed fromF04.batch-get-limit) is addressed by this head.
Non-blocking observations (no action required)
- The generated TypeScript schema (
clients/typescript/src/generated/agent-server-schema.ts) is not regenerated here, but that file is produced by thegenerate:agent-server-apistep in the version-bump/release workflows, andmaxItemsis not runtime-enforced by the TS client anyway. A TS batch of 100 ids now surfaces the 422 instead of a 500, which is the intended, in-scope behavior; client-side chunking is an explicit non-goal. - 0-id requests remain a 422 via the unchanged required
Query()semantics — same as base.
No material correctness, security, compatibility, or acceptance-criterion defect found.
✅ APPROVED
5 tasks
1 of 5 tasks
1 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HUMAN:
This PR proposes a fix for a bug uncovered during the first full agentic run of
verify-agent-server.AGENT:
I'm an AI agent (Claude Code) helping Engel Nyst (@enyst) with project maintenance.
Requested by Engel · project thread
Why
GET /api/conversations(the batch get) accepts at most 99 ids, but the limit was a bareassert len(ids) < 100. With 100 or more ids the failed assertion reached the catch-all handler and came back as500 {"detail": "Internal Server Error", "exception": ""}. The caller had no way to tell it had sent too many ids, the limit was missing from OpenAPI, and the check disappeared underpython -O.Summary
ids: Annotated[list[UUID], Query(max_length=99)]and drop the assert. 100+ ids now get a 422 ("List should have at most 99 items"), the service is not called, and OpenAPI showsmaxItems: 99, following the declaredle=100on searchlimit([Bug]: GET /api/conversations/search returns 500 for limit > 100 (no graceful clamp) #5114).AssertionError), the 99-id 200, and the OpenAPI bound.# bugmarker from theF04.batch-get-limitmap bullet. The recipe now expects a 422 whose body saysat most 99 items.As the issue triage scoped it, the 99-id limit stays the same and the TypeScript client gets no chunking. A TS batch of 100 ids now gets the 422 instead of a 500.
REST API contract changes
Compared with base OpenAPI
6a298a48fcdbfor public/api/**paths.Issue Number
Fixes #5790
How to Test
uv run pytest -q tests/agent_server/test_conversation_router.py tests/agent_server/test_openapi_contract.py: 108 passed. With the router change reverted, the two batch tests (too_many_ids,openapi_declares_id_limit) fail.AGENT_SERVER_VERIFY_HOMEisolated:control-agent-server map run --file F04 --only F04.batch-get-limit --fresh --repeat 2 --checkout <main checkout>reportsxfailin both attempts.xpassin both attempts.control-agent-server map checkis ok, andmap run --file F04 --only F04.batch-get-limit --freshreportspass.uv run pre-commit run --files <changed files>passes.Video/Screenshots
n/a
Type
Notes
Tracked in the umbrella #5653.
🤖 Generated with Claude Code
https://claude.ai/code/session_014MKndVj7XWvRQmvW9w2bDg
Generated by Claude Code
🐳 Agent Server images for this PR — GHCR package, pull/run commands, and all pushed tags (click to expand)
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdkpython-node-runtimepython-node-runtimepython-node-runtimegolang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:f2ac77c-pythonRun
All tags pushed for this build
About Multi-Architecture Support
f2ac77c-python) is a multi-arch manifest supporting both amd64 and arm64f2ac77c-python-amd64) are also available if needed