> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# execute • AI Agent SDK

> execute: Execute a task synchronously - backward compatibility method

# execute

<div className="flex items-center gap-2">
  <Badge color="purple">Method</Badge>
</div>

> This is a method of the [**Agent**](../classes/Agent) class in the [**agent**](../modules/agent) module.

Execute a task synchronously - backward compatibility method

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def execute(task: Any, context: Any) -> Any
```

## Parameters

<ParamField query="task" type="Any" required={true}>
  No description available.
</ParamField>

<ParamField query="context" type="Any" required={false}>
  No description available.
</ParamField>

### Returns

<ResponseField name="Returns" type="Any">
  The result of the operation.
</ResponseField>

## Uses

* `chat`

## Used By

* [`CodeAgent.execute_code`](../functions/CodeAgent-execute_code)
* [`CodeAgent.aexecute`](../functions/CodeAgent-aexecute)
* [`MiddlewareManager.execute_model_call`](../functions/MiddlewareManager-execute_model_call)
* [`MiddlewareManager.execute_tool_call`](../functions/MiddlewareManager-execute_tool_call)
* [`HookRunner.execute_sync`](../functions/HookRunner-execute_sync)

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/agent/agent.py#L6739">
  `praisonaiagents/agent/agent.py` at line 6739
</Card>
