{"record":{"id":"6a0bb4eb27252507","repo":"can1357/oh-my-pi","slug":"devin-assignmodel-error-response-status-respo","errorCode":null,"errorMessage":"Devin AssignModel error ${response.status} ${response.statusText}: ${new TextDecoder().decode(payload)}","messagePattern":"Devin AssignModel error (.+?) (.+?): (.+?)","errorType":"exception","errorClass":"AIError.DevinApiError","httpStatus":null,"severity":"error","filePath":"packages/ai/src/providers/devin.ts","lineNumber":552,"sourceCode":"\tconst request = create(AssignModelRequestSchema, {\n\t\tmetadata: create(MetadataSchema, devinCliMetadata(turn.apiKey)),\n\t\tmodelRouterUid: model.requestModelId ?? model.id,\n\t\tcascadeId: turn.cascadeId,\n\t\tchatMessagePrompt: buildRouterPrompt(turn.messages),\n\t});\n\tconst response = await fetchImpl(`${baseUrl}${DEVIN_ASSIGN_MODEL_PATH}`, {\n\t\tmethod: \"POST\",\n\t\theaders: {\n\t\t\t\"content-type\": \"application/proto\",\n\t\t\t\"connect-protocol-version\": \"1\",\n\t\t\taccept: \"*/*\",\n\t\t},\n\t\tbody: toBinary(AssignModelRequestSchema, request),\n\t\tsignal,\n\t});\n\tconst payload = new Uint8Array(await response.arrayBuffer());\n\tif (!response.ok) {\n\t\tthrow new AIError.DevinApiError(\n\t\t\t`Devin AssignModel error ${response.status} ${response.statusText}: ${new TextDecoder().decode(payload)}`,\n\t\t\tresponse.status,\n\t\t);\n\t}\n\tconst assignment = decodeDevinUnaryMessage(AssignModelResponseSchema, payload)?.assignment;\n\tif (!assignment?.assignmentJwt || !assignment.modelUid) {\n\t\tthrow new AIError.ProviderResponseError(\n\t\t\t\"Devin AssignModel error: response carried no assignment JWT and model uid\",\n\t\t\t{ provider: model.provider, kind: \"runtime\" },\n\t\t);\n\t}\n\tlogger.debug(\"devin: router assigned a model\", {\n\t\trouter: model.requestModelId ?? model.id,\n\t\tassigned: assignment.modelUid,\n\t});\n\treturn assignment;\n}\n","sourceCodeStart":534,"sourceCodeEnd":570,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/ai/src/providers/devin.ts#L534-L570","documentation":"Thrown by assignDevinModel when the Devin AssignModel HTTP call returns a non-2xx status; the response body text is embedded in the message and the status is attached to the DevinApiError. streamDevin calls this to obtain a per-session model assignment before streaming, so any rejection here aborts the whole request.","triggerScenarios":"POST AssignModel responds 400/401/403/404/429/500 — invalid model UID in the request, bad auth token from the earlier auth step, the requested model not available to the account, or rate limiting.","commonSituations":"Requesting a model ID the Devin router does not know or the account cannot access; expired router credentials; Devin service degradation; model UID typo in configuration.","solutions":["Verify the requested model ID/UID is valid and available for your Devin account","Re-authenticate — a stale user JWT can cause 401/403 on AssignModel; retry from the auth step","Read the embedded response body in the message for the server's specific rejection reason","If 429, back off and retry; if 5xx check Devin service health"],"exampleFix":"// before: unknown model id\nmodel: \"gpt-99-turbo\"\n// after: a model UID your Devin instance exposes\nmodel: \"claude-sonnet-4-5\"","handlingStrategy":"try-catch","validationCode":"// Pre-check the model exists on the instance before AssignModel:\nconst models = await fetch(`${devinBaseUrl}/models`, { headers: { authorization: `Bearer ${jwt}` } }).then(r => r.json());\nif (!models.some(m => m.uid === modelUid)) throw new Error(`Model ${modelUid} not available on Devin instance`);","typeGuard":"function isDevinApiError(err: unknown): err is InstanceType<typeof AIError.DevinApiError> {\n  return err instanceof AIError.DevinApiError && typeof err.status === \"number\";\n}","tryCatchPattern":"try {\n  const assignment = await assignDevinModel(model, request, signal);\n} catch (err) {\n  if (err instanceof AIError.DevinApiError && err.status === 429) {\n    await Bun.sleep(backoffMs); // rate limited — retry after backoff\n  } else if (err instanceof AIError.DevinApiError && err.status === 404) {\n    throw new Error(`Model ${model.requestModelId ?? model.id} not found — fix the model config`);\n  } else throw err;\n}","preventionTips":["Validate model IDs against the instance's model list before assigning","Refresh router credentials whenever the auth step re-issues a JWT","Distinguish 429 (backoff) from 404 (config bug) in your catch handling","Pin model IDs in config with comments documenting availability"],"tags":["devin","http","model-assignment","api"],"backgroundTag":"http-request-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}