Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions openhands-sdk/openhands/sdk/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,13 @@ def _coerce_inputs(cls, data):
if d.get("top_p", 1.0) == 1.0:
d["top_p"] = 0.9

# Databricks models have a max_tokens limit of 25000
# Cap max_output_tokens if not already set or if it exceeds the limit
if model_val.startswith("databricks/"):
current_max = d.get("max_output_tokens")
if current_max is None or current_max > 25000:
d["max_output_tokens"] = 25000

return d

@model_validator(mode="after")
Expand Down
15 changes: 15 additions & 0 deletions openhands-sdk/openhands/sdk/llm/options/chat_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ def select_chat_options(
if "max_completion_tokens" in out:
out["max_tokens"] = out.pop("max_completion_tokens")

# Databricks -> uses max_tokens (not max_completion_tokens) and caps at 25000
# Also doesn't support metadata parameter
if llm.model.startswith("databricks/"):
# Get the effective max tokens value
effective_max = out.get("max_tokens") or out.get("max_completion_tokens")
if effective_max and effective_max > 25000:
# Note: Cannot use logger here as it's not available in this context
# The capping happens silently as in other parameter normalizations
effective_max = 25000
# Databricks uses max_tokens parameter (not max_completion_tokens)
out["max_tokens"] = effective_max or 25000
out.pop("max_completion_tokens", None)
# Databricks doesn't support metadata parameter
out.pop("metadata", None)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a metadata?


# If user didn't set extra_headers, propagate from llm config
if llm.extra_headers is not None and "extra_headers" not in out:
out["extra_headers"] = dict(llm.extra_headers)
Expand Down
Loading