Repository navigation
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueNo actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Option contract, forwarding, and validation src/api/generateObject.ts, src/api/runtime/__tests__/generateObject.serviceTier.e2e.test.ts, docs/orchestration/STRUCTURED_OUTPUT_API.md, docs/features/PROMPT_CACHING.md |
GenerateObjectOptions adds serviceTier and customModelParams. generateObject() forwards defined values on each attempt. Documentation and tests cover request fields, validation retries, and omission of service_tier when no tier is set. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Possibly related PRs
- framerslab/agentos#568: Changes Anthropic structured-output routing for
customModelParamstool settings, which this change exposes throughgenerateObject(). - framerslab/agentos#563: Changes Anthropic structured-output route selection and handling of passthrough request settings used by
generateObject(). - framerslab/agentos#558: Changes Anthropic structured-output routing and request overrides in the provider pipeline used by
generateObject().
Merge Risk: 
Minimal · previous review dd685
-
No merge-blocking issue was identified in the new option forwarding.
Pre-merge checks: 
5
-
Full details: Title check
-
Explanation
The title "fix(api): generateObject forwards serviceTier and customModelParams" names the main change. The changeset adds both options to GenerateObjectOptions and forwards them to generateText() on each attempt, including validation retries. The title follows Conventional Commits and is specific. It is 67 characters, within a typical length.
Full details: Description check
-
Explanation
The description covers the summary, the type of change, verification, and the checklist. It explains the problem, the fix, and the vendor reference. It names the tests and how they were verified, and it states that the first push held failing tests. The Linked issues section is missing, although the template only gives an example there. The Migration notes section is absent, which is acceptable because the change does not break existing users. The unchecked item 'Every automated review thread is settled' is an open checklist item, not a missing section. The author should add a linked issue if one exists.
Resolution
Optional: add a linked issue under the Linked issues heading if one exists (for example, 'Fixes
#123'). Otherwise, state that no issue is linked. Settle the automated review threads or leave the checklist item open with a reason.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files. (2 skipped: 2 unsupported.)
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Reviewer's GuideAdds Sequence diagram for generateObject provider option forwardingsequenceDiagram
participant Caller
participant generateObject
participant generateText
participant OpenAIProvider
Caller->>generateObject: generateObject with serviceTier and customModelParams
generateObject->>generateText: generateText with serviceTier and customModelParams
generateText->>OpenAIProvider: request with service_tier and customModelParams
OpenAIProvider-->>generateText: response
alt validation fails
generateObject->>generateText: retry generateText with serviceTier and customModelParams
generateText->>OpenAIProvider: retry request with service_tier and customModelParams
OpenAIProvider-->>generateText: retry response
end
generateText-->>generateObject: generated result
generateObject-->>Caller: structured result
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
PR Summary by Qodofix(api): forward service tier and custom parameters in generateObject
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
Code Review by Qodo
1.
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/api/generateObject.ts" line_range="320-329" />
<code_context>
+ * project's configured tier. `'flex'` bills at about batch rates but can answer 429 under load; `'priority'` is a
+ * paid tier. Other providers ignore it.
+ */
+ serviceTier?: GenerateTextOptions['serviceTier'];
+
+ /**
+ * Provider-specific top-level request fields, forwarded to {@link GenerateTextOptions.customModelParams} and
+ * spread onto every attempt's request body, a validation retry included, with the same rules as there: a fallback
+ * leg gets them minus the fields only another vendor accepts (OpenRouter's routing controls, Gemini's request
+ * fields), and keys collide last-wins with the typed fields at the provider layer. A passthrough `tool_choice`, `tools` or `response_format` here can change the
+ * structured-output route this call takes ({@link generateObject}).
+ */
+ customModelParams?: Record<string, unknown>;
+
/**
</code_context>
<issue_to_address>
**Streaming structured calls lack options**
When a caller needs incremental structured output and also needs either of these request controls, callers switching from `generateObject()` to `streamObject()` still cannot request a service tier or pass provider-specific fields: `StreamObjectOptions` does not declare them, and its `streamText()` call cannot forward them. The structured-output APIs therefore expose different request controls.
Add both options to `StreamObjectOptions` and forward them to its `streamText()` call.
</issue_to_address>| serviceTier?: GenerateTextOptions['serviceTier']; | ||
|
|
||
| /** | ||
| * Provider-specific top-level request fields, forwarded to {@link GenerateTextOptions.customModelParams} and | ||
| * spread onto every attempt's request body, a validation retry included, with the same rules as there: a fallback | ||
| * leg gets them minus the fields only another vendor accepts (OpenRouter's routing controls, Gemini's request | ||
| * fields), and keys collide last-wins with the typed fields at the provider layer. A passthrough `tool_choice`, `tools` or `response_format` here can change the | ||
| * structured-output route this call takes ({@link generateObject}). | ||
| */ | ||
| customModelParams?: Record<string, unknown>; |
There was a problem hiding this comment.
🟡 Medium · Streaming structured calls lack options
When a caller needs incremental structured output and also needs either of these request controls, callers switching from generateObject() to streamObject() still cannot request a service tier or pass provider-specific fields: StreamObjectOptions does not declare them, and its streamText() call cannot forward them. The structured-output APIs therefore expose different request controls.
Add both options to StreamObjectOptions and forward them to its streamText() call.
Prompt for AI agents
In `src/api/generateObject.ts` at lines 320-329:
**Streaming structured calls lack options**
When a caller needs incremental structured output and also needs either of these request controls, callers switching from `generateObject()` to `streamObject()` still cannot request a service tier or pass provider-specific fields: `StreamObjectOptions` does not declare them, and its `streamText()` call cannot forward them. The structured-output APIs therefore expose different request controls.
Add both options to `StreamObjectOptions` and forward them to its `streamText()` call.…d fallback legs drop the other vendor's structured-output field
Summary
generateText()andstreamText()takeserviceTierandcustomModelParamsand send them to the provider.generateObject()takes neither, so a structured call cannot ask for a service tier or pass a provider field the typed options do not model.Input:
generateObject({ model: 'openai:gpt-6-luna', schema, prompt, serviceTier: 'priority' }). The Chat Completions request OpenAI receives has noservice_tier, becausegenerateObject()builds itsgenerateText()call from a fixed list of options and these two are not on it.Change:
GenerateObjectOptionsgainsserviceTierandcustomModelParams, and each attempt'sgenerateText()call forwards them, a validation retry included. They reach the provider exactly as they do fromgenerateText()(fallback legs getcustomModelParamsby the same rules). The TSDoc and the options table indocs/orchestration/STRUCTURED_OUTPUT_API.mddescribe them.Vendor facts: OpenAI's Chat Completions reference describes
service_tieras the processing type for the request, withauto(the project's setting, the default when unset),default,flexandpriority, and says the response reports the tier that served it: https://developers.openai.com/api/reference/resources/chat/subresources/completions/methods/createType of change
How this was verified
src/api/runtime/__tests__/generateObject.serviceTier.e2e.test.tsdrivesgenerateObject()through the realOpenAIProviderwith onlyfetchstubbed and reads the request body OpenAI would receive:service_tierand thecustomModelParamsfields are on the first request and on a validation retry, and noservice_tieris sent when the call names none. AgenerateText()case with the same options is the reference. The first push carries the tests alone and fails at those assertions; the second carries the fix. CI runs the whole suite.Checklist
Summary by CodeRabbit
generateObject()now acceptsserviceTierand provider-specific request parameters, giving you more control over generated responses.generateObject(), retries, and fallback providers.