Repository navigation
Add native responses #622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Add native responses #622
Changes from 17 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
ad36e9a
native responses, clean up
enyst 6c8bfa3
refactor message, serialization and reading
enyst 809ecaf
tweak
enyst 1ec94df
fix telemetry
enyst ffbb3bb
fix typing
enyst 5120a97
Add FACTS.txt with one project fact
openhands-agent 640bfd0
Remove FACTS.txt
openhands-agent 8efe577
use typed reasoning
enyst f223ddc
chore: ignore .worktrees and remove from index (no embedded repos)
enyst fe3509d
chore: remove mistakenly committed .worktrees gitlinks
enyst 3d1fe96
fix agent oops
enyst 430a4e4
fix reasoning types
enyst 3be1a21
fix display
enyst 5a906ae
examples: conversation-only Responses reasoning demo (format)
enyst d26d510
fix input_text (assistant can only be output); clean up a little
enyst 4d0a158
clean up a little
enyst 30bf50d
use standard model features
enyst 2ec226e
fix tests, types
enyst ab97401
tests: add unit tests for Responses API (#634)
enyst bb3d93f
Fix import (#636)
enyst 88f710a
Update .gitignore
enyst d7f9482
Update examples/01_hello_world.py
enyst b0aad14
Update examples/26_responses_reasoning.py
enyst 56ac872
tests(llm): move LLM import to top-level in responses serialization test
enyst f1bb293
Merge branch 'main' into response
enyst a439ecd
tests(sdk): add coverage for Responses API message/tool gaps
enyst e83af81
tests(sdk): fix output coercion tests for Observation wrapping when o…
enyst a578e4f
tests(sdk): adjust non-function tool_call test to avoid LiteLLM type …
enyst d9d8bd5
tests(sdk): rename Action class in responses tool security test to av…
enyst 2784a5a
tests(agent): add Agent.step routing test for Responses vs Completion…
enyst 1b8e97b
tests(agent): add model-features based gating test for Agent.step
enyst 966150f
Update openhands/sdk/llm/message.py
enyst 3f073c9
Merge branch 'main' into response
enyst b46dbc4
merge: align response branch with main refactor for non-executable to…
enyst c9c5b38
dudup code
xingyaoww e0f2a63
adjust formatting
xingyaoww fa4aec6
add comment back
xingyaoww d3d948a
minor simplification
xingyaoww 14ccfc8
Update openhands/sdk/tool/tool.py
enyst 64eba97
adapt test
enyst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -203,3 +203,5 @@ cache | |
| /workspace/ | ||
| openapi.json | ||
| .client/ | ||
| # Git worktrees | ||
| .worktrees/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| """ | ||
| Example: Responses API path via LiteLLM in a Real Agent Conversation | ||
|
|
||
| - Runs a real Agent/Conversation to verify /responses path works | ||
| - Demonstrates rendering of Responses reasoning within normal conversation events | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import os | ||
|
|
||
| from pydantic import SecretStr | ||
|
|
||
| from openhands.sdk import ( | ||
| Conversation, | ||
| Event, | ||
| LLMConvertibleEvent, | ||
| get_logger, | ||
| ) | ||
| from openhands.sdk.llm import LLM | ||
| from openhands.tools.preset.default import get_default_agent | ||
|
|
||
|
|
||
| logger = get_logger(__name__) | ||
|
|
||
|
|
||
| def run_agent_conversation(llm: LLM) -> None: | ||
| print("\n=== Agent Conversation using /responses path ===") | ||
| agent = get_default_agent( | ||
| llm=llm, | ||
| cli_mode=True, # disable browser tools for env simplicity | ||
| ) | ||
|
|
||
| llm_messages = [] # collect raw LLM-convertible messages for inspection | ||
|
|
||
| def conversation_callback(event: Event): | ||
| if isinstance(event, LLMConvertibleEvent): | ||
| llm_messages.append(event.to_llm_message()) | ||
|
|
||
| conversation = Conversation( | ||
| agent=agent, | ||
| callbacks=[conversation_callback], | ||
| workspace=os.getcwd(), | ||
| ) | ||
|
|
||
| # Keep the tasks short for demo purposes | ||
| conversation.send_message("Read the repo and write one fact into FACTS.txt.") | ||
| conversation.run() | ||
|
|
||
| conversation.send_message("Now delete FACTS.txt.") | ||
| conversation.run() | ||
|
|
||
| print("=" * 100) | ||
| print("Conversation finished. Got the following LLM messages:") | ||
| for i, message in enumerate(llm_messages): | ||
| ms = str(message) | ||
| print(f"Message {i}: {ms[:200]}{'...' if len(ms) > 200 else ''}") | ||
|
|
||
|
|
||
| def main(): | ||
| # Prefer proxy credentials commonly used in this repo's examples | ||
|
enyst marked this conversation as resolved.
Outdated
|
||
| api_key = os.getenv("LITELLM_API_KEY") or os.getenv("OPENAI_API_KEY") | ||
| assert api_key, "Set LITELLM_API_KEY or OPENAI_API_KEY in your environment." | ||
|
|
||
| model = os.getenv("OPENAI_RESPONSES_MODEL", "openai/gpt-5-mini") | ||
| base_url = os.getenv("LITELLM_BASE_URL", "https://llm-proxy.eval.all-hands.dev") | ||
|
|
||
| llm = LLM( | ||
| model=model, | ||
| api_key=SecretStr(api_key), | ||
| base_url=base_url, | ||
| # Responses-path options | ||
| enable_encrypted_reasoning=True, # request encrypted reasoning passthrough | ||
| reasoning_effort="high", | ||
| # Logging / behavior tweaks | ||
| log_completions=False, | ||
| drop_params=True, | ||
| service_id="agent", | ||
| ) | ||
|
|
||
| # Run Agent + Conversation using /responses routing | ||
| run_agent_conversation(llm) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.