Fixes#2219
Adds default=str to json.dumps() calls to handle non-JSON-serializable
types like datetime objects in tool function results.
Co-authored-by: kishikawa-hayato <84244732+HerBest-max@users.noreply.github.com>
* Potential fix for code scanning alert no. 18: Information exposure through an exception
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
* Fix test
---------
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
* First working version
* Simplify the implementations
* Remove unused env var
* Update Python syntax
* Address feedbacks
* Fix a typo
* Update names as review suggestions
* Citation for self-reflection
* Move to independent folder
* Update python/samples/getting_started/evaluation/azure_ai_foundry/evaluation/README.md
Co-authored-by: Eduard van Valkenburg <eavanvalkenburg@users.noreply.github.com>
* Updated from parquet to JSONL and hide the default environment variables
* As review feedback, remove the purpose of using `run_self_reflection_batch` as a library, only use it as sample code
* Update python/samples/getting_started/evaluation/azure_ai_foundry/evaluation/self_reflection.py
Co-authored-by: Eduard van Valkenburg <eavanvalkenburg@users.noreply.github.com>
---------
Co-authored-by: Eduard van Valkenburg <eavanvalkenburg@users.noreply.github.com>
* first work on declarative
* initial version of the declarative support
* fix tests and mypy
* fix parameters of functiontool
* slight logic improvement
* remove path until merge
* updates from comments
* create dispatcher and spec type, json_schema method
* fix mypy, skipping model
* updated lock
* fixed declarative tests and renamed some other test files
* refined loader
* updated lock
* fix mypy
* added readme to samples folder
* fixes from review
* undid test file rename
Eduard van Valkenburg
·
2025-11-19 16:33:02 +00:00
* fix: resolve string annotations in FunctionExecutor
Enhance type hint validation in FunctionExecutor by importing `typing` and
using `get_type_hints` to correctly resolve annotations.
This fixes validation failures when `from __future__ import annotations`
is enabled, which stores annotations as strings.
Fixes#1808
* Update python/packages/core/tests/workflow/test_function_executor_future.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* ran pre commit
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Fix bug where ChatAgent system instructions were not captured in Langfuse
traces due to incorrect attribute access.
The observability code was attempting to retrieve instructions using
getattr(self, "instructions", None), but ChatAgent stores instructions
in self.chat_options.instructions. This caused system_instructions to
always be None in Langfuse traces.
Changed both _trace_agent_run and _trace_agent_run_stream functions
to correctly retrieve instructions from chat_options.instructions.
Fixes affect:
- Line 1123: _trace_agent_run (non-streaming)
- Line 1192: _trace_agent_run_stream (streaming)
* Fix: Prevent duplicate MCP tools and prompts (#1876)
- Added deduplication logic in MCPTool.load_tools() method
- Added deduplication logic in MCPTool.load_prompts() method
- Track existing function names before loading from MCP server
- Skip tools/prompts that are already registered in _functions list
- Prevents 400 error from Azure AI Foundry caused by duplicate tool names
The issue occurred because load_tools() was being called multiple times
(during connect() and by notification handlers), causing tools to be
appended without duplicate checking.
Changes made:
1. In load_tools(): Added existing_names set to track registered functions
2. In load_tools(): Added check to skip tools already in existing_names
3. In load_prompts(): Applied same deduplication pattern
Testing:
- Created unit test verifying deduplication logic
- Confirmed duplicates are skipped correctly
- Confirmed new functions are added correctly
- Prevents duplicate tool names being sent to LLM
Fixes#1876
* Address review feedback: Prevent multiple calls to load_tools and load_prompts
- Added _tools_loaded and _prompts_loaded flags to MCPTool class
- Modified load_tools() to check if already loaded and return early
- Modified load_prompts() to check if already loaded and return early
- Moved test cases from test_mcp_fix.py to test_mcp.py
- Added tests for multiple call prevention
- Deleted separate test_mcp_fix.py file
Addresses review feedback from @eavanvalkenburg:
- Prevents accidental multiple calls to load_tools()
- Prevents accidental multiple calls to load_prompts()
- Test file now in proper location (test_mcp.py)
* Address review feedback: Move flag checks to connect() and remove comments
- Removed verbose comments from code
- Moved _tools_loaded and _prompts_loaded checks to connect() method
- Allows manual calls to load_tools() and load_prompts() for updates
- Updated tests to reflect new behavior
- connect() now prevents duplicate loading during connection
- Users can still manually call load_tools()/load_prompts() to refresh
Addresses feedback from @eavanvalkenburg
* Fix: Code quality and formatting issues
- Applied black formatting
- Fixed ruff linting issues
- All tests passing locally
* chore: Re-run uv lock per review request
* Apply pre-commit formatting: consolidate type annotations
- Consolidate multi-line type annotations to single line
- Remove unnecessary parentheses
- Apply ruff format and security checks
* fix devui regression from #2021 where all input is stringified but devui HIL input does not handle stringified json strings correctly.
* update incorrect test
* add devui hil input tests
This commit fixes three issues in the security_filter_middleware:
1. Missing context.terminate flag - Without this, middleware continues processing after setting blocked response
2. No streaming support - When context.is_streaming is True, middleware now returns async generator with ChatResponseUpdate
3. Checks all messages - Changed to check only context.messages[-1] (most recent user message) instead of iterating through conversation history
Changes:
- Added AsyncIterable import
- Added ChatResponseUpdate and TextContent imports
- Modified security_filter_middleware to handle both streaming and non-streaming modes
- Added context.terminate = True to properly stop execution
- Changed message checking logic to only inspect the last user message
Co-authored-by: Victor Dibia <chuvidi2003@gmail.com>
Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com>