refine response format#467
Conversation
PR Summary by QodoRefine response_format handling by moving it into LLM config Description
Diagram
High-Level Assessment
Files changed (5)
|
Code Review by Qodo
1. Template config shadows agent
|
| function changeResponseFormat(e) { | ||
| const value = e?.detail?.selecteds?.map((/** @type {any} */ x) => x.value)[0] || null; | ||
| template.response_format = value; | ||
| if (!template.llm_config) { | ||
| template.llm_config = { provider: null, model: null }; | ||
| } | ||
| template.llm_config.response_format = value; | ||
| handleAgentChange(); |
There was a problem hiding this comment.
1. Template config shadows agent 🐞 Bug ≡ Correctness
changeResponseFormat() now creates template.llm_config = { provider: null, model: null } just to
store response_format, making template.llm_config truthy even when the template should otherwise
inherit agent settings. Downstream, InstructionAgent prefers selectedTemplate.llm_config over
selectedAgent.llm_config, which can clear provider/model and break LLM selection for that
template.
Agent Prompt
## Issue description
Setting a template response format creates a non-null `template.llm_config` with `provider/model = null`, and other screens treat `template.llm_config` as a complete override (not a partial overlay). This causes agent-level provider/model to be lost when selecting that template.
## Issue Context
- `InstructionAgent` currently computes `llmConfig` via `selectedTemplate?.llm_config || selectedAgent?.llm_config`, so any non-null template config wins, even if it only contains `response_format`.
## Fix Focus Areas
- src/routes/page/agent/[agentId]/agent-components/templates/agent-template-config.svelte[91-97]
- src/routes/page/instruction/instruction-components/instruction-agent.svelte[37-69]
## Recommended fix
Pick one of these (prefer 1 or 2):
1) **Treat template.llm_config as a partial override** in `InstructionAgent` by merging:
- Start from `selectedAgent.llm_config`
- Overlay only non-null/non-undefined fields from `selectedTemplate.llm_config`
- Ensure `provider/model` fall back to agent values when template values are null
2) **Don’t instantiate `template.llm_config` when only response_format is set**, unless the rest of the app supports partial-template configs everywhere. (E.g., store template response format separately, or only set `template.llm_config` when provider/model/max tokens/etc are configured.)
3) Add an explicit “inherit agent llm_config” behavior for templates, and ensure `response_format` can override without forcing provider/model overrides.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
No description provided.