Skip to content

fix(tools): persist strict flag in FunctionTool component config - #8292

Open
JingHao-Leon wants to merge 1 commit into
microsoft:mainfrom
JingHao-Leon:fix/function-tool-strict-config
Open

JingHao-Leon wants to merge 1 commit into
microsoft:mainfrom
JingHao-Leon:fix/function-tool-strict-config

Conversation

@JingHao-Leon

Copy link
Copy Markdown

Description

FunctionTool.dump_component() omitted the strict flag from FunctionToolConfig, so a tool created with strict=True came back as strict=False after a dump_component/load_component round trip — confirmed on autogen-core 0.7.5 from PyPI as well as main.

This matters beyond the flag: for tools used with structured output (output_content_type), the docs require strict=True; silently losing it makes the provider stop enforcing the JSON schema, degrading structured-output calls to best-effort parsing with no error anywhere. Anything that persists component configs (serialized teams, worker setups) resets every strict=True tool this way.

Changes

  • FunctionToolConfig: add strict: bool = False
  • _to_config: persist self._strict
  • _from_config: pass config.strict through to the constructor
  • Tests: round-trip preserves strict=True; default remains False

Related issue

Fixes #8283

Verification

pytest python/packages/autogen-core/tests/test_component_config.py -k function_tool
-> 2 passed (the two new tests)

Note: test_function_tool in the same file fails on clean main without this change (pre-existing, unrelated — an async-def collection issue under the current pytest), so CI baseline should show the same single failure.

FunctionTool.dump_component omitted the strict flag from FunctionToolConfig,
so a tool created with strict=True came back as strict=False after a
dump_component/load_component round trip. For tools used with structured
output (output_content_type), the docs require strict=True; silently losing
it makes the provider stop enforcing the JSON schema with no error anywhere.

Add strict to the config model, _to_config, and _from_config, and cover both
the round-trip and the default in tests.

Fixes microsoft#8283
@JingHao-Leon

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FunctionTool(strict=True) loses strict across dump_component / load_component

1 participant