This commit is contained in:
Timothy Jaeryang Baek
2026-08-23 14:40:48 -04:00
parent fb4f476316
commit 78f48a21ee
6 changed files with 434 additions and 7 deletions
+25 -2
View File
@@ -952,6 +952,26 @@ def clean_openai_tool_schema(spec: dict) -> dict:
return cleaned_spec
def add_terminal_display_file_inline_param(spec: dict) -> dict:
spec = copy.deepcopy(spec)
if spec.get('name') != 'display_file':
return spec
spec['description'] = (
f"{spec.get('description', '')} "
"Set inline=true when the file should be shown inline in the chat message instead of opening the file viewer. "
"After calling display_file with inline=true, do not emit Markdown image or link syntax for that file."
).strip()
parameters = spec.setdefault('parameters', {'type': 'object', 'properties': {}, 'required': []})
parameters.setdefault('type', 'object')
properties = parameters.setdefault('properties', {})
properties['inline'] = {
'type': 'boolean',
'description': 'Show the file inline in the chat message instead of opening the file viewer.',
}
return spec
@cache
def get_builtin_function_introspection(func: Callable):
try:
@@ -1408,7 +1428,7 @@ async def get_terminal_tools(
tools_dict = {}
for spec in specs:
function_name = spec['name']
tool_spec = clean_openai_tool_schema(spec)
tool_spec = clean_openai_tool_schema(add_terminal_display_file_inline_param(spec))
if function_name == 'run_command' and terminal_cwd:
tool_spec['description'] = (
@@ -1555,7 +1575,10 @@ async def get_tool_servers_data(servers: list[dict[str, Any]]) -> list[dict[str,
response = {
'openapi': response,
'info': response.get('info', {}),
'specs': convert_openapi_to_tool_payload(response),
'specs': [
add_terminal_display_file_inline_param(spec)
for spec in convert_openapi_to_tool_payload(response)
],
}
openapi_data = response.get('openapi', {})