Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

docs: document context_length_exceeded and the gateway 413 (#731)

Alfredo Lopez285a5aca7b8f
diff --git a/docs/architecture/codex-subscription-transport-contract.md b/docs/architecture/codex-subscription-transport-contract.md
index 9ab821fe5..a9dc4b8f9 100644
--- a/docs/architecture/codex-subscription-transport-contract.md
+++ b/docs/architecture/codex-subscription-transport-contract.md
@@ -258,7 +258,16 @@ behavior changes:
Stable codes: `insufficient_scope`, `no_grant`, `model_not_allowed`,
`budget_denied`, `connection_unavailable`, `provider_unavailable`,
`origin_denied`, `ticket_invalid`, `ticket_replayed`, `request_hash_mismatch`,
-`tool_call_limit_exceeded`.
+`tool_call_limit_exceeded`, `context_length_exceeded`.
+
+- `context_length_exceeded`: the upstream refused the request because it
+ exceeds the model's context window. The upstream sends an SSE `error` event
+ (`error.code`) and a `response.failed` event (`response.error.code`) with
+ this code; the proxy forwards it as HTTP 400, or as an SSE error frame when
+ text had already been streamed. It is the only upstream code the proxy
+ forwards: a failure with any other upstream code, or none, stays
+ `provider_unavailable`. The Host maps it to `LLM_CONTEXT_LENGTH_EXCEEDED`,
+ not retryable, like `request_limit_exceeded`.
- `tool_call_limit_exceeded`: the upstream response carried more than
`maxToolCalls` tool calls. The proxy returns HTTP 422, or an SSE error frame
@@ -269,7 +278,10 @@ Stable codes: `insufficient_scope`, `no_grant`, `model_not_allowed`,
- `request_limit_exceeded` (Host-side only): the turn carries too much. The
Host raises it before authorization — so no provider attempt is spent — and
maps it to `LLM_CONTEXT_LENGTH_EXCEEDED`, not retryable, which the UI shows
- as "Conversation Too Long".
+ as "Conversation Too Long". The Host also raises it when the authorize call
+ gets an HTTP 413 with no JSON error code: that response comes from the
+ workflow-approval gateway's `client_max_body_size`, in front of
+ control-api, and no provider attempt is spent either.
Four of the contract's `limit` refusals mean this, and the Host classifies on
the refusal message because `hashCanonicalCodexRequest` returns
diff --git a/docs/architecture/grok-subscription-transport-contract.md b/docs/architecture/grok-subscription-transport-contract.md
index aaa42a481..b26378f06 100644
--- a/docs/architecture/grok-subscription-transport-contract.md
+++ b/docs/architecture/grok-subscription-transport-contract.md
@@ -282,7 +282,12 @@ Stable codes: `insufficient_scope`, `no_grant`, `model_not_allowed`,
- `request_limit_exceeded` (Host-side only): the turn carries too much. The
Host raises it before authorization — so no provider attempt is spent — and
maps it to `LLM_CONTEXT_LENGTH_EXCEEDED`, not retryable, which the UI shows
- as "Conversation Too Long".
+ as "Conversation Too Long". The Host also raises it when the authorize call
+ gets an HTTP 413 with no JSON error code: that response comes from the
+ workflow-approval gateway's `client_max_body_size`, in front of
+ control-api, and no provider attempt is spent either. The Grok proxy does
+ not yet forward an upstream context-window refusal; unlike Codex, the Grok
+ upstream's code for it has not been recorded.
Four of the contract's `limit` refusals mean this, and the Host classifies on
the refusal message because `hashCanonicalGrokRequest` returns
diff --git a/tests/e2e/fixtures/codex-subscription/sanitized-upstream-contract.json b/tests/e2e/fixtures/codex-subscription/sanitized-upstream-contract.json
index bfabd1092..537a5a1bc 100644
--- a/tests/e2e/fixtures/codex-subscription/sanitized-upstream-contract.json
+++ b/tests/e2e/fixtures/codex-subscription/sanitized-upstream-contract.json
@@ -61,7 +61,8 @@
"ticket_invalid",
"ticket_replayed",
"request_hash_mismatch",
- "tool_call_limit_exceeded"
+ "tool_call_limit_exceeded",
+ "context_length_exceeded"
],
"termsAndTestAccount": {
"automationAuthorized": true,
diff --git a/tests/e2e/fixtures/package-lock.json b/tests/e2e/fixtures/package-lock.json
index 85e91fde0..3a9bac504 100644
--- a/tests/e2e/fixtures/package-lock.json
+++ b/tests/e2e/fixtures/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@clerum/e2e-test-fixtures",
- "version": "1.0.89",
+ "version": "1.0.90",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@clerum/e2e-test-fixtures",
- "version": "1.0.89",
+ "version": "1.0.90",
"dependencies": {
"@kubernetes/client-node": "^1.0.0"
},
diff --git a/tests/e2e/fixtures/package.json b/tests/e2e/fixtures/package.json
index 19d45b543..91a0be7f9 100644
--- a/tests/e2e/fixtures/package.json
+++ b/tests/e2e/fixtures/package.json
@@ -1,6 +1,6 @@
{
"name": "@clerum/e2e-test-fixtures",
- "version": "1.0.89",
+ "version": "1.0.90",
"description": "E2E test fixtures and utilities for Clerum testing",
"type": "module",
"main": "index.ts",
diff --git a/tests/e2e/integration/codex-subscription-contract-freeze.test.ts b/tests/e2e/integration/codex-subscription-contract-freeze.test.ts
index 7398fb860..0cd706816 100644
--- a/tests/e2e/integration/codex-subscription-contract-freeze.test.ts
+++ b/tests/e2e/integration/codex-subscription-contract-freeze.test.ts
@@ -165,6 +165,7 @@ describe('codex-subscription contract freeze', () => {
expect(String(code)).toMatch(/^[a-z][a-z0-9_]+$/)
}
expect(errors).toContain('tool_call_limit_exceeded')
+ expect(errors).toContain('context_length_exceeded')
const terms = contract.termsAndTestAccount as Record<string, unknown> | undefined
expect(terms && typeof terms === 'object').toBe(true)
diff --git a/tests/e2e/package-lock.json b/tests/e2e/package-lock.json
index 6c6c23be7..2c10f9a69 100644
--- a/tests/e2e/package-lock.json
+++ b/tests/e2e/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-e2e-tests",
- "version": "0.1.86",
+ "version": "0.1.87",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-e2e-tests",
- "version": "0.1.86",
+ "version": "0.1.87",
"devDependencies": {
"@types/jsonwebtoken": "^9.0.10",
"@types/node": "^22.0.0",
diff --git a/tests/e2e/package.json b/tests/e2e/package.json
index 7f9f2ae67..da4a3e8a1 100644
--- a/tests/e2e/package.json
+++ b/tests/e2e/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-e2e-tests",
- "version": "0.1.86",
+ "version": "0.1.87",
"private": true,
"type": "module",
"scripts": {