diff --git a/docs.json b/docs.json index d48b9fcf..105fbd10 100644 --- a/docs.json +++ b/docs.json @@ -278,6 +278,7 @@ "sdk/guides/agent-custom", "sdk/guides/agent-file-based", "sdk/guides/agent-stuck-detector", + "sdk/guides/agent-ask-oracle", "sdk/guides/agent-tom-agent", "sdk/guides/critic" ] diff --git a/sdk/guides/agent-ask-oracle.mdx b/sdk/guides/agent-ask-oracle.mdx new file mode 100644 index 00000000..31ca24cf --- /dev/null +++ b/sdk/guides/agent-ask-oracle.mdx @@ -0,0 +1,40 @@ +--- +title: Ask Oracle +description: Let an agent consult a saved Oracle LLM profile for stateless second-opinion advice. +--- + +import RunExampleCode from "/sdk/shared-snippets/how-to-run-example.mdx"; + +> A ready-to-run example is available [here](#ready-to-run-example)! + +Use `ask_oracle` when the active agent should ask a stronger or more specialized saved LLM profile for a second opinion without switching its own active profile. + +## When to Use It + +`ask_oracle` is useful when an agent is stuck, comparing approaches, or wants another model to review a risky decision. The Oracle call is stateless from the Oracle's point of view: it receives a dedicated Oracle system prompt plus the agent's question and optional context, returns a text recommendation, and does not take over the conversation. + +## Configure the Oracle Profile + +First save the LLM you want to use as the Oracle with `LLMProfileStore`. Then set `oracle_llm_profile` on `OpenHandsAgentSettings` to the saved profile name. + +```python icon="python" focus={10} wrap +from openhands.sdk import LLM, OpenHandsAgentSettings + +settings = OpenHandsAgentSettings( + llm=LLM(model="openai/gpt-5-nano"), + oracle_llm_profile="oracle", +) +agent = settings.create_agent() +``` + +When `oracle_llm_profile` is unset, the tool is not added. When it is set, the agent receives an `ask_oracle` tool and can consult that saved profile while keeping its regular LLM unchanged. + +## Ready-to-run Example + + +This example is available on GitHub: [examples/01_standalone_sdk/54_ask_oracle_tool/main.py](https://github.com/OpenHands/software-agent-sdk/blob/main/examples/01_standalone_sdk/54_ask_oracle_tool/main.py) + + +```python icon="python" expandable examples/01_standalone_sdk/54_ask_oracle_tool/main.py +# content is auto-synced +```