Skip to main content
A ready-to-run example is available here!
Use ask_oracle when an agent should consult a stronger or more specialized model for a second opinion without switching its active model.

When to Use It

ask_oracle is useful when an agent is:
  • Stuck or uncertain about its next step
  • Comparing implementation approaches
  • Reviewing a risky or difficult decision
  • Asked by the user to get a second opinion

How It Works

When the agent calls ask_oracle:
  1. The tool loads the saved LLM profile named oracle.
  2. The Oracle receives a dedicated system prompt and a user message containing the agent’s question and optional context.
  3. The Oracle returns a text recommendation to the original agent.
  4. The original agent continues the conversation with its existing model.
The Oracle does not receive the conversation history or any tools. It cannot modify the workspace directly. Its token usage and cost are included in the conversation’s combined metrics.
The tool does not fall back to the agent’s active model. If the oracle profile is missing or cannot be loaded, the tool returns an error observation telling the agent that the Oracle is unavailable.

Configure the Oracle Profile

The tool resolves its model by convention from a saved LLM profile named oracle. There is no dedicated agent setting for selecting another profile. To enable it:
  1. Save a usable LLM configuration under the name oracle. See LLM Profile Store.
  2. Add AskOracleTool to the agent’s tools:
By default, LocalConversation reads profiles from ~/.openhands/profiles. If you use a custom profile directory, pass the same directory to both LLMProfileStore and LocalConversation through profile_store_dir.
Do not place literal API keys in source code. The ready-to-run example reads its key from the environment and stores the Oracle profile in a temporary directory, which is removed after the example exits. Follow the LLM Profile Store guidance when creating a persistent profile.

Ask Oracle vs. Switch LLM

ask_oracle makes one stateless call to another model and then returns control to the original agent. It never changes the active conversation model. Use switch_profile() or the switch_llm tool instead when subsequent agent turns should run on a different saved profile. See LLM Profile Store.

Ready-to-run Example

This example is available on GitHub: examples/01_standalone_sdk/58_ask_oracle_tool/main.py
examples/01_standalone_sdk/58_ask_oracle_tool/main.py
You can run the example code as-is.
The model name should follow the LiteLLM convention: provider/model_name (e.g., anthropic/claude-sonnet-4-5-20250929, openai/gpt-4o). The LLM_API_KEY should be the API key for your chosen provider.
ChatGPT Plus/Pro subscribers: You can use LLM.subscription_login() to authenticate with your ChatGPT account and access Codex models without consuming API credits. See the LLM Subscriptions guide for details.

Next Steps