Skip to main content
AgentContext is passed to your run and unwind functions. It has session data and all SDK methods.

Session Data

  • sessionId (number): Unique session identifier
  • sessionWalletAddress (string): Wallet address for this session
  • currentPositions (array): Assets allocated to the agent at the start of execution
  • executionMode (string): "auto" or "manual"

SDK Methods

  • log(): Send messages to users and log locally
  • memory: Session-scoped key-value storage
  • platforms: Platform integrations (Polymarket, Hyperliquid)
  • swidge: Cross-chain swap and bridge operations
  • signAndSend(): Sign and broadcast transactions
  • signMessage(): Sign messages (EVM only)
  • transactions(): Get transaction history
  • getCurrentPositions(): Get live positions
  • clearSuggestedTransactions(): Clear pending suggestions (manual mode)

Basic Usage

async function run(agent: AgentContext): Promise<void> {
  await agent.log(`Session: ${agent.sessionId}`);
  await agent.log(`Wallet: ${agent.sessionWalletAddress}`);
  await agent.log(`Positions: ${agent.currentPositions.length}`);
}

Current Positions

currentPositions is a snapshot taken at execution start. After transactions, use getCurrentPositions() for updated balances. See Positions for full details.
const positions = await agent.getCurrentPositions();
if (positions.success && positions.data) {
  if (positions.data.hasPendingTxs) {
    await agent.log("Pending transactions detected");
  }
  // Use positions.data.positions
}

See Also