# Print the assistant's final answer
final_message = next(
    item for item in response.output if item["type"] == "message" and item["role"] == "assistant"
)
print(final_message["content"][0]["text"])
```

## Best practices

- **Sandbox or containerize** execution. Consider using Docker, firejail, or a
  jailed user account.
- **Impose resource limits** (time, memory, network). The `timeout_ms` provided
  by the model is only a hintâyou should enforce your own limits.
- **Filter or scrutinize** high-risk commands (e.g. `rm`, `curl`, network
  utilities).
- **Log every command and its output** for auditability and debugging.

### Error handling

If the command fails on your side (non-zero exit code, timeout, etc.) you can
still send a `local_shell_call_output`; include the error message in the
`output` field.

The model can choose to recover or try executing a different command. If you
send malformed data (e.g. missing `call_id`) the API returns a standard `400`
validation error.