feat: allow changing default agent tools
This commit is contained in:
parent
d5958e2134
commit
4b051807ff
2 changed files with 10 additions and 9 deletions
|
|
@ -176,15 +176,15 @@ impl Agent {
|
|||
let now = chrono::Utc::now().to_rfc3339();
|
||||
|
||||
if existing.is_default {
|
||||
if existing.name != name || existing.role != role || existing.tool != tool {
|
||||
if existing.name != name || existing.role != role {
|
||||
return Err(rusqlite::Error::InvalidParameterName(
|
||||
"Default agents cannot change name, role, or tool".to_string(),
|
||||
"Default agents cannot change name or role".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
conn.execute(
|
||||
"UPDATE agents SET custom_prompt = ?1, updated_at = ?2 WHERE id = ?3",
|
||||
params![custom_prompt, now, id],
|
||||
"UPDATE agents SET tool = ?1, custom_prompt = ?2, updated_at = ?3 WHERE id = ?4",
|
||||
params![tool.as_str(), custom_prompt, now, id],
|
||||
)?;
|
||||
return Ok(());
|
||||
}
|
||||
|
|
@ -308,7 +308,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_update_default_agent_allows_prompt_only() {
|
||||
fn test_update_default_agent_allows_tool_and_prompt_only() {
|
||||
let conn = setup();
|
||||
let analyst = Agent::get_default_by_role(&conn, AgentRole::Analyst).unwrap();
|
||||
|
||||
|
|
@ -323,19 +323,20 @@ mod tests {
|
|||
.unwrap_err();
|
||||
assert!(err
|
||||
.to_string()
|
||||
.contains("Default agents cannot change name, role, or tool"));
|
||||
.contains("Default agents cannot change name or role"));
|
||||
|
||||
Agent::update(
|
||||
&conn,
|
||||
&analyst.id,
|
||||
&analyst.name,
|
||||
analyst.role.clone(),
|
||||
analyst.tool.clone(),
|
||||
AgentTool::ClaudeCode,
|
||||
"Prompt override",
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let updated = Agent::get_by_id(&conn, &analyst.id).unwrap();
|
||||
assert_eq!(updated.tool, AgentTool::ClaudeCode);
|
||||
assert_eq!(updated.custom_prompt, "Prompt override");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,8 @@ export default function AgentForm() {
|
|||
{initializing && <div className="text-sm text-gray-500">Loading agent...</div>}
|
||||
{isEditing && isDefaultAgent && (
|
||||
<div className="rounded border border-blue-200 bg-blue-50 p-3 text-sm text-blue-700">
|
||||
This is a default agent. Only its script/prompt can be modified.
|
||||
This is a default agent. Its tool and script/prompt can be modified, but its name and
|
||||
role are fixed.
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
|
@ -116,7 +117,6 @@ export default function AgentForm() {
|
|||
<select
|
||||
value={tool}
|
||||
onChange={(e) => setTool(e.target.value as AgentTool)}
|
||||
disabled={isEditing && isDefaultAgent}
|
||||
className="w-full rounded border border-gray-300 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||
>
|
||||
<option value="codex">Codex</option>
|
||||
|
|
|
|||
Loading…
Reference in a new issue