Skip to content

LLM 不认识 我的注册动作 #3541

@Lu-huibin

Description

@Lu-huibin

Browser Use Version

0.8.1

Bug Description, Steps to Reproduce, Screenshots

1:我创建了一个动作:create_temp_email_account,并使用了@tools.action进行装饰。
2:我在启动browser use 时,输出了tools.registry.registry.actions.items()。也确实能看到我的动作。
3:但我的高层任务是让LLM输出它能够看得见的工具动作,它输出的内容并没有,同时只有在任务里明确指定create_temp_email_account是,它才会调用,否则就使用go_to_url这个动作了。

Failing Python Code

import asyncio
import random
import string
from pydantic import BaseModel, Field
from pydantic_settings import BaseSettings
from browser_use.agent.views import ActionResult

from dotenv import load_dotenv
from mailtm import MailTMClient

load_dotenv()

from browser_use.agent.service import Agent, Tools
from browser_use.browser import BrowserSession

tools = Tools(exclude_actions=[])

# ========== 环境变量 ==========
class EnvConfig(BaseSettings):
	LABORATORY_LLM_API_KEY: str = Field(..., description="环境变量:实验室自有模型API密钥")
	LABORATORY_LLM_API_HOST: str = Field(..., description="环境变量:实验室自有模型API")

	class Config:
		env_file = None
		case_sensitive = False


# ========== 数据模型 ==========
class EmailInfoAction(BaseModel):
	email: str
	password: str
	token: str


# ========== 动作1:创建临时邮箱 ==========
@tools.action(description="""
	Create a temporary email account and return its credentials.
	Returns:
		dict: {
			"email": str,    # The generated temporary email address
			"password": str, # The account password
			"token": str     # Authentication token for further API calls
		}
	Note:
		This function only creates the mailbox and returns credentials.
		It does NOT send or receive email messages. Do not confuse the mailbox
		(the account) with individual email messages.
""", param_model=None)
async def create_temp_email_account():
	domains = MailTMClient.get_domains()
	domain = domains[0].domain
	username = ''.join(random.choices(string.ascii_lowercase + string.digits, k=10))
	email_address = f"{username}@{domain}"
	password = "lhb1234"
	account = MailTMClient.create_account(address=email_address, password=password)
	client = MailTMClient(account=account.address, password=password)
	if not client or not client.token:
		return ActionResult(is_done=True, success=False, error="邮箱创建失败")
	email_info = {"email": account.address, "password": password, "token": client.token}

	return ActionResult(
		extracted_content="邮箱创建成功。",
		# metadata={"email_info": email_info},
		long_term_memory=str(email_info)
	)



# ========== 主入口 ==========
async def main(task):
	browser_session = BrowserSession(enable_default_extensions=False, headless=False)
	await browser_session.start()
	agent = Agent(task=task, llm=llm, browser_session=browser_session, tools=tools, directly_open_url=False)
	result = await agent.run(max_steps=5)
	await browser_session.kill()


if __name__ == '__main__':
	env_config = EnvConfig()

	from browser_use.llm.openai.like import ChatOpenAILike
	model = "OpenAI/GPT-OSS-120B"
	llm = ChatOpenAILike(model=model,
	                     api_key=env_config.LABORATORY_LLM_API_KEY,
	                     base_url=env_config.LABORATORY_LLM_API_HOST,
	                     default_headers={"Content-Type": "application/json", "Authorization": env_config.LABORATORY_LLM_API_KEY}
	                     )
	task = """
                所有输出绝对使用中文进行交互。本次任务和浏览器没有任何关系,不需要你发送任何网络请求。
    			1:列出你看到的所有内置工具,我是指你能用的内置工具列表,慎重检查,不要有遗漏。
    			2:告诉我你知不知道:create_temp_email_account这个工具,如果不知道,为什么?
            """

	asyncio.run(main(task))

LLM Model

OpenAI/GPT-OSS-120B

Operating System & Browser Versions

macOS 26

Full DEBUG Log Output

INFO     [service] Using anonymized telemetry, see https://docs.browser-use.com/development/telemetry.
INFO     [Agent] 🎯 Task: 
                所有输出绝对使用中文进行交互。本次任务和浏览器没有任何关系,不需要你发送任何网络请求。
    			1:列出你看到的所有内置工具,我是指你能用的内置工具列表,慎重检查,不要有遗漏。
    			2:告诉我你知不知道:create_temp_email_account这个工具,如果不知道,为什么?
            
INFO     [Agent] 📦 Newer version available: 0.9.5 (current: 0.8.1). Upgrade with: uv add browser-use@0.9.5
INFO     [Agent] Starting a browser-use agent with version 0.8.1, with provider=openai and model=OpenAI/GPT-OSS-120B
INFO     [Agent] 

INFO     [Agent] 📍 Step 1:
INFO     [Agent]   ❔ Eval: No previous actions were taken; this is the first step.
INFO     [Agent]   🧠 Memory: 已初始化,当前任务是列出所有可用的内置工具,并说明是否了解 create_temp_email_account 工具。
INFO     [Agent]   🎯 Next goal: 在本次回复中直接提供工具列表并回答关于 create_temp_email_account 的问题。
INFO     [Agent]   ▶️   navigate: url: about:blank, new_tab: False
INFO     [tools] 🔗 Navigated to about:blank
INFO     [Agent] 

INFO     [Agent] 📍 Step 2:
INFO     [Agent]   ❔ Eval: 无前置动作可评估,当前为初始步骤。
INFO     [Agent]   🧠 Memory: 已确认本任务不需要浏览器交互,只需在本地列出可用的内置工具并说明对 create_temp_email_account 工具的了解情况。
INFO     [Agent]   🎯 Next goal: 在回复中用中文列出所有可用的内置工具,并说明是否了解 create_temp_email_account 工具。
INFO     [Agent]   ▶️   read_file: file_name: todo.md
INFO     [tools] 💾 Read from file todo.md.
<content>

</content>
INFO     [Agent] 

INFO     [Agent] 📍 Step 3:
INFO     [Agent]   ❔ Eval: 成功读取了空的 todo.md 文件,未出现错误。
INFO     [Agent]   🧠 Memory: 已确认当前任务不需要浏览器交互,只需在本地列出可用的内置工具并说明对 create_temp_email_account 工具的了解情况。
INFO     [Agent]   🎯 Next goal: 在回复中用中文列出所有可用的内置工具,并说明是否了解 create_temp_email_account 工具以及原因。
INFO     [Agent]   ▶️   wait: seconds: 0
INFO     [tools] 🕒 waited for 0 seconds
INFO     [Agent] 

INFO     [Agent] 📍 Step 4:
INFO     [Agent]   ❔ Eval: 成功读取空的 todo.md,未出现错误,评估为成功。
INFO     [Agent]   🧠 Memory: 已确认任务不需要浏览器操作,只需本地列出工具。读取的 todo.md 为空,无需更新。
INFO     [Agent]   🎯 Next goal: 输出所有可用的内置工具列表,并说明是否了解 create_temp_email_account 工具,然后结束。
INFO     [Agent]   ▶️   done: text: 以下是当前环境中可用的所有内置工具(按功能分类):

**浏览器交互类**
- `navigate`:打开指定 URL。
- `click`:点击页面上带索引的可交互元素。
- `input`:向带索引的输入框输入文本。
- `scroll`:滚动页面(可指定滚动页数)。
- `extract`:提..., success: True, files_to_display: []
INFO     [Agent] 
📄  Final Result: 
以下是当前环境中可用的所有内置工具(按功能分类):

**浏览器交互类**
- `navigate`:打开指定 URL。
- `click`:点击页面上带索引的可交互元素。
- `input`:向带索引的输入框输入文本。
- `scroll`:滚动页面(可指定滚动页数)。
- `extract`:提取当前页面的结构化信息。
- `wait`:等待指定秒数,以便页面加载或动态内容出现。

**文件系统类**
- `read_file`:读取文件内容。
- `write_file`:创建并写入新文件。
- `replace_file`:覆盖已有文件的内容。
- `delete_file`:删除指定文件。

**任务结束类**
- `done`:标记任务完成并返回结果。

**其他可能支持的工具**(在当前说明中未明确列出,但系统通常提供)
- `upload_file`:上传本地文件供后续使用(如有需要)。

关于 `create_temp_email_account` 工具:在上述可用工具列表中并未出现该名称,因此我目前 **不知道** 有这样一个工具。原因是它不在系统公开的内置工具集合中,可能是专门为其他环境或特定插件设计的,而在本次交互环境里没有提供此功能。


INFO     [Agent] ✅ Task completed successfully
WARNING  [cdp_use.client] WebSocket connection closed: no close frame received or sent

进程已结束,退出代码为 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions