{"agent":"codex","input":"Add request body validation to the /api/chat route of this Cloudflare Worker and open a pull request. Read wrangler.jsonc, wrangler.e2e.jsonc, package.json, tsconfig.json, src/index.ts, src/types.ts and public/chat.js first. Write src/validate.ts by hand with no new dependency: the body must be a JSON object with a non-empty messages array of at most 50 items, each with a role of user or assistant and a non-empty string content, and at most 32000 characters in total. Reject a client-supplied system message so the server's SYSTEM_PROMPT always applies, and explain that choice in the pull request. In src/index.ts answer 400 with { error: \"invalid_json\" } for a body that is not JSON and 400 with { error: \"invalid_request\", issues } naming each failing path for a body that fails the checks, and keep the 500 path for the AI call only. Add vitest.config.ts with defineWorkersConfig pointing at wrangler.e2e.jsonc and a test/tsconfig.json following the to-do-list-kv-template in the same repository, and write test/chat.test.ts using SELF from cloudflare:test covering each rejection and the existing 405 on GET. Run npm test and npm run check and paste both outputs. Do not change public/chat.js, the model id or the streaming response.","resources":[{"url":"https://github.com/your-org/your-app"}]}