Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/browser-use/agent-sdk
/ functions
Functions
249 in github.com/browser-use/agent-sdk
⨍
Functions
249
◇
Types & classes
64
↳
Endpoints
2
↓ 12 callers
Function
_truncate
Truncate text to max_length characters, adding ellipsis if truncated.
bu_agent_sdk/llm/messages.py:11
↓ 10 callers
Method
ainvoke
Invoke the model with the given messages and optional tools. Args: messages: List of chat messages tools: Op
bu_agent_sdk/llm/google/chat.py:366
↓ 9 callers
Method
serialize_messages
Convert a list of BaseMessages to Google format, extracting system message. Google handles system instructions separately from the c
bu_agent_sdk/llm/google/serializer.py:43
↓ 6 callers
Method
_serialize_cache_control
Serialize cache control.
bu_agent_sdk/llm/anthropic/serializer.py:62
↓ 5 callers
Function
_is_debug_mode
Check if we're in debug mode based on environment variables.
bu_agent_sdk/observability.py:54
↓ 5 callers
Method
resolve_path
Resolve and validate a path is within the sandbox.
bu_agent_sdk/examples/claude_code.py:57
↓ 4 callers
Method
_check_and_compact
Check token usage and compact if threshold exceeded. The threshold is calculated dynamically based on the model's context window. Ar
bu_agent_sdk/agent/service.py:582
↓ 4 callers
Function
_create_no_op_decorator
Create a no-op decorator that accepts all lmnr observe parameters but does nothing.
bu_agent_sdk/observability.py:65
↓ 4 callers
Method
_serialize_content_part_text
( part: ContentPartTextParam, )
bu_agent_sdk/llm/openai/serializer.py:37
↓ 4 callers
Method
create
Create a new sandbox context, defaulting to a temp directory.
bu_agent_sdk/examples/claude_code.py:46
↓ 4 callers
Method
resolve
Resolve the dependency, handling both sync and async callables. Args: overrides: Optional dict mapping original dependency functions to
bu_agent_sdk/tools/depends.py:59
↓ 3 callers
Method
_fetch_and_cache_pricing_data
Fetch pricing data from LiteLLM GitHub and cache it with timestamp
bu_agent_sdk/tokens/service.py:132
↓ 3 callers
Method
_make_strict_schema
Transform schema for OpenAI strict mode: all properties must be required.
bu_agent_sdk/llm/openai/chat.py:201
↓ 3 callers
Method
_serialize_content_part_text
Convert a text content part to Anthropic's TextBlockParam.
bu_agent_sdk/llm/anthropic/serializer.py:69
↓ 3 callers
Method
ainvoke
Invoke the model with the given messages and optional tools. Args: messages: List of chat messages forming the conversation.
bu_agent_sdk/llm/base.py:80
↓ 3 callers
Method
create_optimized_json_schema
Create the most optimized schema by flattening all $ref/$defs while preserving FULL descriptions and ALL action definitions. Also ens
bu_agent_sdk/llm/schema.py:18
↓ 2 callers
Function
_create_async_gen_observe_decorator
Create a decorator for async generators that wraps them in a Laminar span.
bu_agent_sdk/observability.py:104
↓ 2 callers
Method
_destroy_ephemeral_messages
Destroy old ephemeral message content, keeping the last N per tool. Tools can specify how many outputs to keep via _ephemeral attribute:
bu_agent_sdk/agent/service.py:229
↓ 2 callers
Method
_execute_tool_call
Execute a single tool call and return the result as a ToolMessage.
bu_agent_sdk/agent/service.py:300
↓ 2 callers
Function
_format_image_url
Format image URL for display, truncating if necessary.
bu_agent_sdk/llm/messages.py:18
↓ 2 callers
Method
_generate_max_iterations_summary
Generate a summary of what was accomplished when max iterations is reached. Uses the LLM to summarize the conversation history and actions ta
bu_agent_sdk/agent/service.py:534
↓ 2 callers
Method
_get_incomplete_todos_prompt
Hook for subclasses to check for incomplete todos before finishing. This method is called when the LLM is about to stop (no more tool calls i
bu_agent_sdk/agent/service.py:569
↓ 2 callers
Method
_invoke_llm
Invoke the LLM with current messages and tools. Includes retry logic with exponential backoff for LLM errors
bu_agent_sdk/agent/service.py:436
↓ 2 callers
Method
_serialize_content_part_image
Convert an image content part to Anthropic's ImageBlockParam.
bu_agent_sdk/llm/anthropic/serializer.py:82
↓ 2 callers
Method
_serialize_system_content
Serialize content for system messages (text only).
bu_agent_sdk/llm/openai/serializer.py:95
↓ 2 callers
Method
_serialize_tools
Convert ToolDefinitions to Google's tool format.
bu_agent_sdk/llm/google/chat.py:184
↓ 2 callers
Method
get_client
Returns a genai.Client instance. Returns: genai.Client: An instance of the Google genai client.
bu_agent_sdk/llm/google/chat.py:130
↓ 2 callers
Method
get_model_pricing
Get pricing information for a specific model
bu_agent_sdk/tokens/service.py:188
↓ 2 callers
Method
get_threshold_for_model
Get the compaction threshold for a specific model.
bu_agent_sdk/agent/compaction/service.py:99
↓ 2 callers
Method
get_usage_summary
Get summary of token usage and costs (costs calculated on-the-fly)
bu_agent_sdk/tokens/service.py:289
↓ 2 callers
Method
initialize
Initialize the service by loading pricing data
bu_agent_sdk/tokens/service.py:58
↓ 2 callers
Method
list_users
(self)
bu_agent_sdk/examples/dependency_injection.py:31
↓ 2 callers
Method
query_stream
Send a message to the agent and stream events as they occur. Yields events for each step of the agent's execution, providing
bu_agent_sdk/agent/service.py:703
↓ 1 callers
Method
__init__
( self, message: str, status_code: int = 502, model: str | None = None, )
bu_agent_sdk/llm/exceptions.py:8
↓ 1 callers
Method
_analyze_signature
Analyze function signature to extract parameters and dependencies.
bu_agent_sdk/tools/decorator.py:182
↓ 1 callers
Method
_build_cache_key
Build a stable cache key for system/tool definitions.
bu_agent_sdk/llm/google/chat.py:272
↓ 1 callers
Method
_clean_cache_messages
Clean cache settings so only the last cache=True message remains cached. Because of how Claude caching works, only the last cache message mat
bu_agent_sdk/llm/anthropic/serializer.py:412
↓ 1 callers
Method
_create_cached_content
Create a cached content resource for stable system/tools.
bu_agent_sdk/llm/google/chat.py:295
↓ 1 callers
Method
_extract_screenshot
Extract screenshot base64 from a tool message if present. Browser tools may return ContentPartImageParam with screenshots. This metho
bu_agent_sdk/agent/service.py:395
↓ 1 callers
Method
_extract_summary
Extract summary content from <summary></summary> tags. If tags are not found, returns the original text. Args: text:
bu_agent_sdk/agent/compaction/service.py:284
↓ 1 callers
Method
_extract_text_content
Extract text content from Anthropic response.
bu_agent_sdk/llm/anthropic/chat.py:234
↓ 1 callers
Method
_extract_text_content
Extract text content from Google response.
bu_agent_sdk/llm/google/chat.py:348
↓ 1 callers
Method
_extract_thinking
Extract thinking and redacted thinking from Anthropic response. Returns: Tuple of (thinking_content, redacted_thinking_data)
bu_agent_sdk/llm/anthropic/chat.py:244
↓ 1 callers
Method
_extract_tool_calls
Extract tool calls from Anthropic response.
bu_agent_sdk/llm/anthropic/chat.py:206
↓ 1 callers
Method
_extract_tool_calls
Extract tool calls from Google response.
bu_agent_sdk/llm/google/chat.py:228
↓ 1 callers
Method
_extract_tool_calls
Extract tool calls from OpenAI response.
bu_agent_sdk/llm/openai/chat.py:273
↓ 1 callers
Method
_find_model_in_pricing_data
Try to find model in pricing data using various name formats.
bu_agent_sdk/tokens/service.py:159
↓ 1 callers
Method
_find_valid_cache
Find the most recent valid cache file
bu_agent_sdk/tokens/service.py:75
↓ 1 callers
Method
_fix_gemini_schema
Convert a Pydantic model to a Gemini-compatible schema. This function removes unsupported properties like 'additionalProperties' and
bu_agent_sdk/llm/google/chat.py:571
↓ 1 callers
Method
_get_client_params
Prepare client parameters dictionary.
bu_agent_sdk/llm/anthropic/chat.py:67
↓ 1 callers
Method
_get_client_params
Prepare client parameters dictionary.
bu_agent_sdk/llm/google/chat.py:113
↓ 1 callers
Method
_get_client_params
Prepare client parameters dictionary.
bu_agent_sdk/llm/openai/chat.py:112
↓ 1 callers
Method
_get_client_params_for_invoke
Prepare client parameters dictionary for invoke.
bu_agent_sdk/llm/anthropic/chat.py:100
↓ 1 callers
Function
_get_param_description
Extract parameter description from docstring if available.
bu_agent_sdk/tools/decorator.py:127
↓ 1 callers
Method
_get_stop_reason
Extract stop_reason from Google response.
bu_agent_sdk/llm/google/chat.py:148
↓ 1 callers
Method
_get_tool_choice
Convert our tool_choice to Anthropic's format.
bu_agent_sdk/llm/anthropic/chat.py:182
↓ 1 callers
Method
_get_tool_choice
Convert our tool_choice to Google's format.
bu_agent_sdk/llm/google/chat.py:201
↓ 1 callers
Method
_get_tool_choice
Convert our tool_choice to OpenAI's format.
bu_agent_sdk/llm/openai/chat.py:256
↓ 1 callers
Method
_get_usage
(self, response: Message)
bu_agent_sdk/llm/anthropic/chat.py:133
↓ 1 callers
Method
_get_usage
( self, response: types.GenerateContentResponse )
bu_agent_sdk/llm/google/chat.py:158
↓ 1 callers
Method
_get_usage
(self, response: ChatCompletion)
bu_agent_sdk/llm/openai/chat.py:151
↓ 1 callers
Method
_is_base64_image
Check if the URL is a base64 encoded image.
bu_agent_sdk/llm/anthropic/serializer.py:39
↓ 1 callers
Method
_is_cache_valid
Check if a specific cache file is valid and not expired
bu_agent_sdk/tokens/service.py:105
↓ 1 callers
Method
_load_from_cache
Load pricing data from a specific cache file
bu_agent_sdk/tokens/service.py:121
↓ 1 callers
Method
_load_pricing_data
Load pricing data from cache or fetch from GitHub
bu_agent_sdk/tokens/service.py:65
↓ 1 callers
Method
_make_strict_compatible
Ensure all properties are required for OpenAI strict mode
bu_agent_sdk/llm/schema.py:220
↓ 1 callers
Method
_make_strict_property
Transform a single property for strict mode, recursively handling nested objects.
bu_agent_sdk/llm/openai/chat.py:217
↓ 1 callers
Method
_parse_base64_url
Parse a base64 data URL to extract media type and data.
bu_agent_sdk/llm/anthropic/serializer.py:44
↓ 1 callers
Method
_prepare_messages_for_summary
Prepare messages for summarization. This removes tool_calls from the last assistant message to avoid API errors (tool_use requires to
bu_agent_sdk/agent/compaction/service.py:244
↓ 1 callers
Function
_python_type_to_json_schema
Convert a Python type to JSON schema type.
bu_agent_sdk/tools/decorator.py:59
↓ 1 callers
Method
_resolve_prompt_cache_retention
Select prompt cache retention based on model support.
bu_agent_sdk/llm/openai/chat.py:246
↓ 1 callers
Method
_serialize_assistant_content
Serialize content for assistant messages (text and refusal allowed).
bu_agent_sdk/llm/openai/serializer.py:111
↓ 1 callers
Method
_serialize_content
Serialize content to Anthropic format.
bu_agent_sdk/llm/anthropic/serializer.py:147
↓ 1 callers
Method
_serialize_content_part_document
Convert a document content part to Anthropic's DocumentBlockParam.
bu_agent_sdk/llm/anthropic/serializer.py:104
↓ 1 callers
Method
_serialize_content_part_image
( part: ContentPartImageParam, )
bu_agent_sdk/llm/openai/serializer.py:43
↓ 1 callers
Method
_serialize_content_part_refusal
( part: ContentPartRefusalParam, )
bu_agent_sdk/llm/openai/serializer.py:52
↓ 1 callers
Method
_serialize_content_to_str
Serialize content to a string.
bu_agent_sdk/llm/anthropic/serializer.py:118
↓ 1 callers
Method
_serialize_result
Serialize the tool result to string or content parts. Returns content parts (list) directly for multimodal results, otherwise seriali
bu_agent_sdk/tools/decorator.py:340
↓ 1 callers
Method
_serialize_tool_call
( tool_call: ToolCall, )
bu_agent_sdk/llm/openai/serializer.py:141
↓ 1 callers
Method
_serialize_tool_calls_to_content
Convert tool calls to Anthropic's ToolUseBlockParam format.
bu_agent_sdk/llm/anthropic/serializer.py:188
↓ 1 callers
Method
_serialize_tool_message
Convert a ToolMessage to Anthropic's ToolResultBlockParam.
bu_agent_sdk/llm/anthropic/serializer.py:235
↓ 1 callers
Method
_serialize_tool_message
Convert a ToolMessage to Google's FunctionResponse Part.
bu_agent_sdk/llm/google/serializer.py:20
↓ 1 callers
Method
_serialize_tool_message_content
Serialize content for tool messages (text only, images converted to text description).
bu_agent_sdk/llm/openai/serializer.py:153
↓ 1 callers
Method
_serialize_tool_result_content
Serialize tool result content for Anthropic.
bu_agent_sdk/llm/anthropic/serializer.py:217
↓ 1 callers
Method
_serialize_tools
Convert ToolDefinitions to Anthropic's tool format. Only the last N tools get cache_control to stay within Anthropic's limit of 4 cache block
bu_agent_sdk/llm/anthropic/chat.py:147
↓ 1 callers
Method
_serialize_tools
Convert ToolDefinitions to OpenAI's tool format.
bu_agent_sdk/llm/openai/chat.py:176
↓ 1 callers
Method
_serialize_user_content
Serialize content for user messages (text and images allowed). No native PDF/document support, so docs converted to a text placeholder.
bu_agent_sdk/llm/openai/serializer.py:60
↓ 1 callers
Method
add_usage
Add token usage entry to history (without calculating cost)
bu_agent_sdk/tokens/service.py:260
↓ 1 callers
Method
calculate_cost
( self, model: str, usage: ChatInvokeUsage )
bu_agent_sdk/tokens/service.py:226
↓ 1 callers
Method
check_and_compact
Check token usage and compact if threshold exceeded. This is the main entry point for the compaction service. It checks if compaction
bu_agent_sdk/agent/compaction/service.py:197
↓ 1 callers
Method
clear_history
Clear the message history and token usage.
bu_agent_sdk/agent/service.py:199
↓ 1 callers
Method
compact
Perform compaction on the message history. This method: 1. Prepares the messages for summarization (removing pending tool calls)
bu_agent_sdk/agent/compaction/service.py:135
↓ 1 callers
Method
execute
Execute the tool function with the given arguments. Handles: - Dependency injection resolution (with optional overrides)
bu_agent_sdk/tools/decorator.py:286
↓ 1 callers
Method
from_usage
Create TokenUsage from ChatInvokeUsage.
bu_agent_sdk/agent/compaction/models.py:117
↓ 1 callers
Method
get_client
Returns an AsyncAnthropic client. Returns: AsyncAnthropic: An instance of the AsyncAnthropic client.
bu_agent_sdk/llm/anthropic/chat.py:119
↓ 1 callers
Method
get_client
Returns an AsyncOpenAI client. Returns: AsyncOpenAI: An instance of the AsyncOpenAI client.
bu_agent_sdk/llm/openai/chat.py:137
↓ 1 callers
Function
get_llm_by_name
Factory function to create LLM instances from string names with API keys from environment. Args: model_name: String name like 'azure
bu_agent_sdk/llm/models.py:88
↓ 1 callers
Method
get_model_context_limit
Get the context window limit for a model.
bu_agent_sdk/agent/compaction/service.py:74
↓ 1 callers
Method
get_usage
Get usage summary for the agent. Returns: UsageSummary with token counts and costs.
bu_agent_sdk/agent/service.py:191
↓ 1 callers
Method
get_user
(self, user_id: int)
bu_agent_sdk/examples/dependency_injection.py:28
next →
1–100 of 249, ranked by callers