fix: include url in web_extract trimmed results & fix docs
The web_extract_tool was stripping the 'url' key during its output
trimming step, but documentation in 3 places claimed it was present.
This caused KeyError when accessing result['url'] in execute_code
scripts, especially when extracting from multiple URLs.
Changes:
- web_tools.py: Add 'url' back to trimmed_results output
- code_execution_tool.py: Add 'title' to _TOOL_STUBS docstring and
_TOOL_DOC_LINES so docs match actual {url, title, content, error}
response format
This commit is contained in:
parent
7bccd904c7
commit
3830bbda41
2 changed files with 3 additions and 2 deletions
|
|
@ -78,7 +78,7 @@ _TOOL_STUBS = {
|
||||||
"web_extract": (
|
"web_extract": (
|
||||||
"web_extract",
|
"web_extract",
|
||||||
"urls: list",
|
"urls: list",
|
||||||
'"""Extract content from URLs. Returns dict with results list of {url, content, error}."""',
|
'"""Extract content from URLs. Returns dict with results list of {url, title, content, error}."""',
|
||||||
'{"urls": urls}',
|
'{"urls": urls}',
|
||||||
),
|
),
|
||||||
"read_file": (
|
"read_file": (
|
||||||
|
|
@ -605,7 +605,7 @@ _TOOL_DOC_LINES = [
|
||||||
" Returns {\"data\": {\"web\": [{\"url\", \"title\", \"description\"}, ...]}}"),
|
" Returns {\"data\": {\"web\": [{\"url\", \"title\", \"description\"}, ...]}}"),
|
||||||
("web_extract",
|
("web_extract",
|
||||||
" web_extract(urls: list[str]) -> dict\n"
|
" web_extract(urls: list[str]) -> dict\n"
|
||||||
" Returns {\"results\": [{\"url\", \"content\", \"error\"}, ...]} where content is markdown"),
|
" Returns {\"results\": [{\"url\", \"title\", \"content\", \"error\"}, ...]} where content is markdown"),
|
||||||
("read_file",
|
("read_file",
|
||||||
" read_file(path: str, offset: int = 1, limit: int = 500) -> dict\n"
|
" read_file(path: str, offset: int = 1, limit: int = 500) -> dict\n"
|
||||||
" Lines are 1-indexed. Returns {\"content\": \"...\", \"total_lines\": N}"),
|
" Lines are 1-indexed. Returns {\"content\": \"...\", \"total_lines\": N}"),
|
||||||
|
|
|
||||||
|
|
@ -787,6 +787,7 @@ async def web_extract_tool(
|
||||||
# Trim output to minimal fields per entry: title, content, error
|
# Trim output to minimal fields per entry: title, content, error
|
||||||
trimmed_results = [
|
trimmed_results = [
|
||||||
{
|
{
|
||||||
|
"url": r.get("url", ""),
|
||||||
"title": r.get("title", ""),
|
"title": r.get("title", ""),
|
||||||
"content": r.get("content", ""),
|
"content": r.get("content", ""),
|
||||||
"error": r.get("error"),
|
"error": r.get("error"),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue