Skip to main content

Overview

The update_agent function updates an existing AI agent’s configuration.

Function Signature

pub async fn update_agent(
    agent_id: &str,
    request: UpdateAiAgentRequest
) -> Result<AiAgent>

Parameters

agent_id
&str
required
The unique identifier of the agent to update
request
UpdateAiAgentRequest
required
The agent fields to update (all optional):
  • name: Agent name
  • description: Agent description
  • instructions: System instructions for the agent
  • temperature: Model temperature
  • is_active: Whether agent is active

Return Value

Returns Result<AiAgent> containing the updated agent details.

Basic Usage

use wacht::api::agents::*;

let update = UpdateAiAgentRequest {
    name: Some("Updated Agent Name".to_string()),
    description: Some("Updated description".to_string()),
    temperature: Some(0.8),
    is_active: Some(false),
    ..Default::default()
};

let updated_agent = update_agent("52057194421551105", update).await?;
println!("Updated agent: {}", updated_agent.name);

Error Handling

match update_agent("52057194421551105", request).await {
    Ok(agent) => {
        println!("Successfully updated agent: {}", agent.name);
        println!("Last updated: {}", agent.updated_at);
        println!("Active status: {}", agent.is_active);
    }
    Err(Error::Api { status, message, .. }) => {
        match status.as_u16() {
            404 => println!("Agent not found"),
            400 => println!("Invalid request: {}", message),
            403 => println!("Access denied: {}", message),
            _ => println!("API error {}: {}", status, message),
        }
    }
    Err(e) => println!("Request failed: {}", e),
}

Rate Limits

  • Update operations: 100 requests per minute
  • Burst limit: 10 requests per second