Skip to main content

Method Signature

agent.run(params: RunParams): Promise<RunResponse>

Description

Manually triggers an agent run to perform yield optimization. This is useful when you want to force an immediate rebalancing check instead of waiting for the automatic schedule.
Agents automatically optimize on a regular schedule. Use run() only when you need to trigger an immediate optimization.

Parameters

wallet
Address
required
Smart account wallet address to run optimization for.

Return Value

status
string
Status of the run operation.

Example

import { GizaAgent, Chain } from '@giza/agent-sdk';

const giza = new GizaAgent({ chainId: Chain.BASE });

// Manually trigger an agent run
const result = await giza.agent.run({
  wallet: smartAccountAddress,
});

console.log('Run status:', result.status);

Error Handling

import { ValidationError, GizaAPIError } from '@giza/agent-sdk';

try {
  const result = await giza.agent.run({
    wallet: smartAccountAddress,
  });
  console.log('Agent run triggered:', result.status);
} catch (error) {
  if (error instanceof ValidationError) {
    console.error('Invalid parameters:', error.message);
  } else if (error instanceof GizaAPIError) {
    console.error('Run failed:', error.message);
  }
}

Common Errors

ErrorCauseSolution
ValidationError: wallet address is requiredMissing wallet parameterProvide a valid wallet address
GizaAPIError: Agent not activeAgent is not in active stateActivate the agent before running
GizaAPIError: Run already in progressAnother run is currently executingWait for the current run to complete

Next Steps