fix(core): support reasoning models in generateTitle by making temperature configurable#1234
Conversation
…ature configurable Reasoning models (gpt-5-mini, o1, o3) reject the temperature parameter. Previously, generateTitle hardcoded temperature: 0, causing silent failures. Changes: - Make temperature optional in generateTitle (omitted by default) - Add temperature field to ConversationTitleConfig - Upgrade error log from debug to warn for visibility Closes VoltAgent#1233
🦋 Changeset detectedLatest commit: 2d0d865 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughConversation title generation no longer forces Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/core/src/agent/agent.ts (1)
4726-4726: Normalizetemperaturebefore forwarding it.
maxOutputTokensandmaxLengthare runtime-guarded, buttemperatureis forwarded for any non-undefinedvalue. A JS/JSON caller passingnull,NaN, orInfinitycan still make title generation fail. Preserve explicit0, but only forward finite numbers.Proposed guard
- const titleTemperature = normalized.temperature; + const titleTemperature = + typeof normalized.temperature === "number" && Number.isFinite(normalized.temperature) + ? normalized.temperature + : undefined;Also applies to: 4755-4755, 4768-4768
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/core/src/agent/agent.ts` at line 4726, Normalize and validate temperature before forwarding: replace direct uses of normalized.temperature (e.g., the titleTemperature assignment and the two other temperature-forwarding sites) with a guarded value that only forwards finite numbers (preserving explicit 0) — use a check like typeof value === 'number' && Number.isFinite(value') to keep the number and otherwise treat it as undefined / omit it when building the downstream options; update the assignments where titleTemperature (and the other two temperature variables referenced) are set so null, NaN, Infinity are not forwarded.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/core/src/agent/agent.ts`:
- Around line 4791-4793: The WARN log in agent.ts uses safeStringify(error)
which will serialize Error objects to {} and lose details; update the
context.logger.warn call inside the conversation title generation catch to
include explicit Error properties (e.g., error.name, error.message, error.stack)
as metadata alongside or instead of safeStringify so the actual failure reason
is preserved; locate the logging at the context.logger.warn("[Memory] Failed to
generate conversation title", ...) site and replace the metadata object to
explicitly expose those Error fields (optionally keep safeStringify(error) as a
fallback field).
---
Nitpick comments:
In `@packages/core/src/agent/agent.ts`:
- Line 4726: Normalize and validate temperature before forwarding: replace
direct uses of normalized.temperature (e.g., the titleTemperature assignment and
the two other temperature-forwarding sites) with a guarded value that only
forwards finite numbers (preserving explicit 0) — use a check like typeof value
=== 'number' && Number.isFinite(value') to keep the number and otherwise treat
it as undefined / omit it when building the downstream options; update the
assignments where titleTemperature (and the other two temperature variables
referenced) are set so null, NaN, Infinity are not forwarded.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4e1f73b6-2207-496e-96d8-9783d78221c0
📒 Files selected for processing (3)
.changeset/fix-generatetitle-reasoning-models.mdpackages/core/src/agent/agent.tspackages/core/src/memory/types.ts
Address CodeRabbit review: safeStringify loses Error properties. Use error.name/message for Error instances.
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/core/src/agent/agent.ts">
<violation number="1" location="packages/core/src/agent/agent.ts:4791">
P2: `safeStringify(error)` will serialize Error objects to `"{}"` because Error properties (`message`, `name`, `stack`) are non-enumerable and `JSON.stringify` skips them. This defeats the purpose of upgrading to `warn` for better failure visibility. Extract error properties explicitly before serializing:
```js
error:
error instanceof Error
? { name: error.name, message: error.message }
: safeStringify(error),
```</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| context.logger.warn("[Memory] Failed to generate conversation title", { | ||
| error: safeStringify(error), |
There was a problem hiding this comment.
P2: safeStringify(error) will serialize Error objects to "{}" because Error properties (message, name, stack) are non-enumerable and JSON.stringify skips them. This defeats the purpose of upgrading to warn for better failure visibility. Extract error properties explicitly before serializing:
error:
error instanceof Error
? { name: error.name, message: error.message }
: safeStringify(error),Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/core/src/agent/agent.ts, line 4791:
<comment>`safeStringify(error)` will serialize Error objects to `"{}"` because Error properties (`message`, `name`, `stack`) are non-enumerable and `JSON.stringify` skips them. This defeats the purpose of upgrading to `warn` for better failure visibility. Extract error properties explicitly before serializing:
```js
error:
error instanceof Error
? { name: error.name, message: error.message }
: safeStringify(error),
```</comment>
<file context>
@@ -4787,7 +4788,7 @@ export class Agent {
}
} catch (error) {
- context.logger.debug("[Memory] Failed to generate conversation title", {
+ context.logger.warn("[Memory] Failed to generate conversation title", {
error: safeStringify(error),
});
</file context>
| context.logger.warn("[Memory] Failed to generate conversation title", { | |
| error: safeStringify(error), | |
| context.logger.warn("[Memory] Failed to generate conversation title", { | |
| error: | |
| error instanceof Error | |
| ? { name: error.name, message: error.message } | |
| : safeStringify(error), |
There was a problem hiding this comment.
Already addressed in the current code — same fix as the CodeRabbit suggestion above.
Summary
Fixes #1233
generateTitlesilently fails with reasoning models (gpt-5-mini,o1,o3) becausetemperature: 0is hardcoded in thegenerateTextcall. Reasoning models reject thetemperatureparameter, causing the call to error and fall back to the default"Conversation"title.Changes
temperature: 0fromcreateConversationTitleGenerator— temperature is now omitted by default, letting the AI SDK / provider use its own defaulttemperaturefield toConversationTitleConfig— users who want deterministic titles with non-reasoning models can explicitly settemperature: 0debugtowarn— makes title generation failures visible without enabling debug loggingHow to test
openai/gpt-5-mini)generateTitle: trueon Memory"Conversation"generateTitle: { temperature: 0 }with a non-reasoning model to verify explicit temperature still worksSummary by cubic
Fixes
generateTitlefailures with reasoning models by making temperature optional and omitted by default. Titles now generate correctly instead of defaulting to "Conversation".temperatureunless provided; provider uses its default.temperaturetoConversationTitleConfig(generateTitle.temperature) for optional control.@voltagent/core: usewarnand preserveErrorname/message.Written for commit 2d0d865. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
New Features