Skip to content

fix(core): support reasoning models in generateTitle by making temperature configurable#1234

Closed
kagura-agent wants to merge 2 commits into
VoltAgent:mainfrom
kagura-agent:fix/generatetitle-reasoning-model-temperature
Closed

fix(core): support reasoning models in generateTitle by making temperature configurable#1234
kagura-agent wants to merge 2 commits into
VoltAgent:mainfrom
kagura-agent:fix/generatetitle-reasoning-model-temperature

Conversation

@kagura-agent

@kagura-agent kagura-agent commented Apr 23, 2026

Copy link
Copy Markdown

Summary

Fixes #1233

generateTitle silently fails with reasoning models (gpt-5-mini, o1, o3) because temperature: 0 is hardcoded in the generateText call. Reasoning models reject the temperature parameter, causing the call to error and fall back to the default "Conversation" title.

Changes

  • Remove hardcoded temperature: 0 from createConversationTitleGenerator — temperature is now omitted by default, letting the AI SDK / provider use its own default
  • Add temperature field to ConversationTitleConfig — users who want deterministic titles with non-reasoning models can explicitly set temperature: 0
  • Upgrade error log from debug to warn — makes title generation failures visible without enabling debug logging

How to test

  1. Configure an agent with a reasoning model (e.g. openai/gpt-5-mini)
  2. Enable generateTitle: true on Memory
  3. Start a conversation → title should now be generated instead of falling back to "Conversation"
  4. Optionally set generateTitle: { temperature: 0 } with a non-reasoning model to verify explicit temperature still works

Summary by cubic

Fixes generateTitle failures with reasoning models by making temperature optional and omitted by default. Titles now generate correctly instead of defaulting to "Conversation".

  • Bug Fixes
    • Omit temperature unless provided; provider uses its default.
    • Added temperature to ConversationTitleConfig (generateTitle.temperature) for optional control.
    • Improved failure logging in @voltagent/core: use warn and preserve Error name/message.

Written for commit 2d0d865. Summary will update on new commits.

Summary by CodeRabbit

  • Bug Fixes

    • Conversation title generation no longer forces a fixed temperature and now respects when no temperature is provided.
    • Title-generation failures are logged at warn level for better visibility; error output is simplified for readability.
  • New Features

    • Added an optional temperature setting for conversation title configuration to allow per-title temperature control.

…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-bot

changeset-bot Bot commented Apr 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2d0d865

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@voltagent/core Patch

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

@coderabbitai

coderabbitai Bot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ceed809f-2df5-40d4-a815-822dc260b3bb

📥 Commits

Reviewing files that changed from the base of the PR and between d0a9667 and 2d0d865.

📒 Files selected for processing (1)
  • packages/core/src/agent/agent.ts

📝 Walkthrough

Walkthrough

Conversation title generation no longer forces temperature: 0. ConversationTitleConfig gains an optional temperature field; the agent conditionally omits or includes temperature when calling the LLM. Title-generation failures are logged at warn (and Error instances are logged with { name, message }).

Changes

Cohort / File(s) Summary
Changeset Metadata
​.changeset/fix-generatetitle-reasoning-models.md
Adds a changeset documenting the patch: remove hardcoded temperature: 0, make temperature configurable/optional for title generation, and raise title-generation log level to warn.
Type Definition
packages/core/src/memory/types.ts
Adds temperature?: number to ConversationTitleConfig.
Agent Implementation
packages/core/src/agent/agent.ts
Title generation now reads titleTemperature and conditionally injects temperature into the LLM span callOptions and generateText request; catch logging elevated from debug to warn and Error instances are logged as { name, message }.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • #986: Prior PR that introduced conversation title generation and related types/logic which this change adjusts to support reasoning models.

Poem

🐇 I once set temperature to nil,
So reasoning models couldn't thrill;
Now optional warmth I bring,
Titles hum and engines sing,
Warn the night — let good titles fill. 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: making temperature configurable in generateTitle to support reasoning models.
Description check ✅ Passed The PR description covers the required sections: summary of what was fixed, detailed changes, and testing instructions aligned with the template.
Linked Issues check ✅ Passed All code changes fully address issue #1233: removing hardcoded temperature, adding temperature configuration option, and upgrading error logging from debug to warn level.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing generateTitle for reasoning models; no unrelated modifications were introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/core/src/agent/agent.ts (1)

4726-4726: Normalize temperature before forwarding it.

maxOutputTokens and maxLength are runtime-guarded, but temperature is forwarded for any non-undefined value. A JS/JSON caller passing null, NaN, or Infinity can still make title generation fail. Preserve explicit 0, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 0b793d9 and d0a9667.

📒 Files selected for processing (3)
  • .changeset/fix-generatetitle-reasoning-models.md
  • packages/core/src/agent/agent.ts
  • packages/core/src/memory/types.ts

Comment thread packages/core/src/agent/agent.ts
Address CodeRabbit review: safeStringify loses Error properties.
Use error.name/message for Error instances.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/core/src/agent/agent.ts Outdated
Comment on lines 4791 to 4792
context.logger.warn("[Memory] Failed to generate conversation title", {
error: safeStringify(error),

@cubic-dev-ai cubic-dev-ai Bot Apr 23, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Suggested change
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),
Fix with Cubic

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already addressed in the current code — same fix as the CodeRabbit suggestion above.

@omeraplak omeraplak closed this Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

generateTitle silently fails with reasoning models (gpt-5-mini, o1, o3) due to hardcoded temperature: 0

2 participants