Skip to content

Commit 946ff55

Browse files
authored
Merge pull request #943 from krissetto/dont-reconfigure-dmr-model-for-title-generation
Don't reconfigure dmr model when generating a title
2 parents a0d2d5f + 22f0098 commit 946ff55

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

pkg/model/provider/clone.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ func CloneWithOptions(ctx context.Context, base Provider, opts ...options.Opt) P
1616
// Preserve existing options, then apply overrides. Later opts take precedence.
1717
baseOpts := options.FromModelOptions(config.ModelOptions)
1818
mergedOpts := append(baseOpts, opts...)
19-
mergedOpts = append(mergedOpts, options.WithGeneratingTitle())
2019

2120
// Apply max_tokens override if present in options
2221
// We need to apply it to the ModelConfig itself since that's what providers use

pkg/model/provider/dmr/client.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,12 @@ func NewClient(ctx context.Context, cfg *latest.ModelConfig, opts ...options.Opt
9494
slog.Warn(w)
9595
}
9696
slog.Debug("DMR provider_opts parsed", "model", cfg.Model, "context_size", contextSize, "runtime_flags", finalFlags, "speculative_opts", specOpts, "engine", engine)
97-
if err := configureDockerModel(ctx, cfg.Model, contextSize, finalFlags, specOpts); err != nil {
98-
slog.Debug("docker model configure skipped or failed", "error", err)
97+
// Skip model configuration when generating titles to avoid reconfiguring the model
98+
// with different settings (e.g., smaller max_tokens) that would affect the main agent.
99+
if !globalOptions.GeneratingTitle() {
100+
if err := configureDockerModel(ctx, cfg.Model, contextSize, finalFlags, specOpts); err != nil {
101+
slog.Debug("docker model configure skipped or failed", "error", err)
102+
}
99103
}
100104

101105
slog.Debug("DMR client created successfully", "model", cfg.Model, "base_url", baseURL)

pkg/runtime/runtime.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,13 @@ func (r *LocalRuntime) generateSessionTitle(ctx context.Context, sess *session.S
14181418
systemPrompt := "You are a helpful AI assistant that generates concise, descriptive titles for conversations. You will be given a conversation history and asked to create a title that captures the main topic."
14191419
userPrompt := fmt.Sprintf("Based on the following message a user sent to an AI assistant, generate a short, descriptive title (maximum 50 characters) that captures the main topic or purpose of the conversation. Return ONLY the title text, nothing else.\n\nUser message: %s\n\n", firstUserMessage)
14201420

1421-
titleModel := provider.CloneWithOptions(ctx, r.CurrentAgent().Model(), options.WithStructuredOutput(nil), options.WithMaxTokens(100))
1421+
titleModel := provider.CloneWithOptions(
1422+
ctx,
1423+
r.CurrentAgent().Model(),
1424+
options.WithStructuredOutput(nil),
1425+
options.WithMaxTokens(100),
1426+
options.WithGeneratingTitle(),
1427+
)
14221428
newTeam := team.New(
14231429
team.WithID("title-generator"),
14241430
team.WithAgents(agent.New("root", systemPrompt, agent.WithModel(titleModel))),

0 commit comments

Comments
 (0)