Description
Flat Responses-style function definitions are accepted as tools, but their names are not recognized by the shared _get_tool_name helper. FunctionInvocationContext.remove_tools("lookup") leaves the flat definition in the live list, and adding a separate flat definition with the same name does not raise the documented duplicate-name error. Nested Chat Completions-style definitions work.
Reproduction Steps
from agent_framework import FunctionInvocationContext
from agent_framework._tools import FunctionTool
lookup = {"type": "function", "name": "lookup", "parameters": {"type": "object"}}
tools = [lookup]
context = FunctionInvocationContext(
function=FunctionTool(name="loader", description="Load tools", func=lambda: None),
arguments={},
tools=tools,
)
context.remove_tools("lookup")
assert tools == [] # fails: lookup remains available
Expected behavior
Flat function mappings should participate in name-based removal and duplicate checks, while non-function built-in tool definitions remain unaffected.
Actual behavior
_get_tool_name only inspects the nested function key. No model, hosted service, or approval flow is needed to reproduce the list-management behavior.
Environment
Current main at 1aca61d; Ubuntu WSL, Python 3.13.16, editable core package. Three focused behavioral regressions fail on the original helper. A local one-line prototype recognizing the flat function shape passes those regressions and all 218 tests in tests/core/test_middleware.py and tests/core/test_tools.py. Ruff and formatting checks pass; this is not full function-loop validation.
Additional context
Fresh issue/open-PR searches found no overlapping report or fix. Since the helper lives in _tools.py and is shared by progressive tool exposure, I am reporting this for core-team confirmation of scope and the required validation before opening a code PR. I can contribute the focused regressions and prototype if this direction is appropriate.
AI assistance: OpenAI Codex reproduced the bug and prepared this report.
Description
Flat Responses-style function definitions are accepted as tools, but their names are not recognized by the shared
_get_tool_namehelper.FunctionInvocationContext.remove_tools("lookup")leaves the flat definition in the live list, and adding a separate flat definition with the same name does not raise the documented duplicate-name error. Nested Chat Completions-style definitions work.Reproduction Steps
Expected behavior
Flat function mappings should participate in name-based removal and duplicate checks, while non-function built-in tool definitions remain unaffected.
Actual behavior
_get_tool_nameonly inspects the nestedfunctionkey. No model, hosted service, or approval flow is needed to reproduce the list-management behavior.Environment
Current main at
1aca61d; Ubuntu WSL, Python 3.13.16, editable core package. Three focused behavioral regressions fail on the original helper. A local one-line prototype recognizing the flat function shape passes those regressions and all 218 tests intests/core/test_middleware.pyandtests/core/test_tools.py. Ruff and formatting checks pass; this is not full function-loop validation.Additional context
Fresh issue/open-PR searches found no overlapping report or fix. Since the helper lives in
_tools.pyand is shared by progressive tool exposure, I am reporting this for core-team confirmation of scope and the required validation before opening a code PR. I can contribute the focused regressions and prototype if this direction is appropriate.AI assistance: OpenAI Codex reproduced the bug and prepared this report.