Commit Graph

104 Commits

  • .NET: Python: Add AGENTS.md files and update coding standards (#3644)
    * Add AGENTS.md files and update coding standards for Python
    
    - Add root python/AGENTS.md with project structure and package links
    - Add AGENTS.md for each package describing purpose and main classes
    - Update .github/copilot-instructions.md with improved structure
    - Update python/CODING_STANDARD.md with API review guidance:
      - Future annotations convention (#3578)
      - TypeVar naming convention (#3594)
      - Mapping vs MutableMapping (#3577)
      - Avoid shadowing built-ins (#3583)
      - Explicit exports (#3605)
      - Exception documentation guidelines (#3410)
    - Simplify python/.github/instructions/python.instructions.md to reference AGENTS.md
    - Remove AGENTS.md from .gitignore
    
    * Fix purview import path in AGENTS.md
    
    * Address PR review comments and restructure instructions
    
    - Slim down .github/copilot-instructions.md to reference language-specific docs
    - Add ADR section explaining templates and purpose
    - Create dotnet/AGENTS.md with .NET-specific build commands, conventions, and sample guidance
    - Update Python build/test instructions for core vs isolated changes
    - Fix Microsoft.Extensions.AI package references
    - Update kwargs guidance per issue #3642
    - Fix Python sample helper placement (top, not bottom)
    - Document new 'typing' poe task in DEV_SETUP.md
    
    * Add 'typing' poe task to run both pyright and mypy
    
    * Add kwargs guidelines from issue #3642 to CODING_STANDARD.md
    
    * Clarify that connector packages pull in core as dependency
  • Python: Fix AG-UI message handling and MCP tool double-call bug (#3635)
    * AG-UI bug fixes
    
    * Fixes
    
    * Fixes
    
    * Revert human_in_the_loop_agent.py changes
    
    * Address copilot feedback
    
    * PR feedback addressed
  • Python: [BREAKING] Types API Review improvements (#3647)
    * Replace Role and FinishReason classes with NewType + Literal
    
    - Remove EnumLike metaclass from _types.py
    - Replace Role class with NewType('Role', str) + RoleLiteral
    - Replace FinishReason class with NewType('FinishReason', str) + FinishReasonLiteral
    - Update all usages across codebase to use string literals
    - Remove .value access patterns (direct string comparison now works)
    - Add backward compatibility for legacy dict serialization format
    - Update tests to reflect new string-based types
    
    Addresses #3591, #3615
    
    * Simplify ChatResponse and AgentResponse type hints (#3592)
    
    - Remove overloads from ChatResponse.__init__
    - Remove text parameter from ChatResponse.__init__
    - Remove | dict[str, Any] from finish_reason and usage_details params
    - Remove **kwargs from AgentResponse.__init__
    - Both now accept ChatMessage | Sequence[ChatMessage] | None for messages
    - Update docstrings and examples to reflect changes
    - Fix tests that were using removed kwargs
    - Fix Role type hint usage in ag-ui utils
    
    * Remove text parameter from ChatResponseUpdate and AgentResponseUpdate (#3597)
    
    - Remove text parameter from ChatResponseUpdate.__init__
    - Remove text parameter from AgentResponseUpdate.__init__
    - Remove **kwargs from both update classes
    - Simplify contents parameter type to Sequence[Content] | None
    - Update all usages to use contents=[Content.from_text(...)] pattern
    - Fix imports in test files
    - Update docstrings and examples
    
    * Rename from_chat_response_updates to from_updates (#3593)
    
    - ChatResponse.from_chat_response_updates → ChatResponse.from_updates
    - ChatResponse.from_chat_response_generator → ChatResponse.from_update_generator
    - AgentResponse.from_agent_run_response_updates → AgentResponse.from_updates
    
    * Remove try_parse_value method from ChatResponse and AgentResponse (#3595)
    
    - Remove try_parse_value method from ChatResponse
    - Remove try_parse_value method from AgentResponse
    - Remove try_parse_value calls from from_updates and from_update_generator methods
    - Update samples to use try/except with response.value instead
    - Update tests to use response.value pattern
    - Users should now use response.value with try/except for safe parsing
    
    * Add agent_id to AgentResponse and clarify author_name documentation (#3596)
    
    - Add agent_id parameter to AgentResponse class
    - Document that author_name is on ChatMessage objects, not responses
    - Update ChatResponse docstring with author_name note
    - Update AgentResponse docstring with author_name note
    
    * Simplify ChatMessage.__init__ signature (#3618)
    
    - Make contents a positional argument accepting Sequence[Content | str]
    - Auto-convert strings in contents to TextContent
    - Remove overloads, keep text kwarg for backward compatibility with serialization
    - Update _parse_content_list to handle string items
    - Update all usages across codebase to use new format: ChatMessage("role", ["text"])
    
    * Allow Content as input on run and get_response
    
    - Update prepare_messages and normalize_messages to accept Content
    - Update type signatures in _agents.py and _clients.py
    - Add tests for Content input handling
    
    * Fix ChatMessage usage across packages and samples
    
    Update all remaining ChatMessage(role=..., text=...) to use new
    ChatMessage('role', ['text']) signature.
    
    * Fix Role string usage and response format parsing
    
    - Fix redis provider: remove .value access on string literals
    - Fix durabletask ensure_response_format: set _response_format before accessing .value
    
    * Fix ollama .value and ai_model_id issues, handle None in content list
    
    - Fix ollama _chat_client: remove .value on string literals
    - Fix ollama _chat_client: rename ai_model_id to model_id
    - Fix _parse_content_list: skip None values gracefully
    
    * Fix A2AAgent type signature to include Content
    
    * Fix Role/FinishReason NewType dict annotations and improve test coverage to 95%
    
    * Fix mypy errors for Role/FinishReason NewType usage
    
    * Fix Role.TOOL and Role.ASSISTANT usage in _orchestrator_helpers.py
    
    * Fix Role NewType usage in durabletask _models.py
  • Python: Add BaseAgent implementation for Claude Agent SDK (#3509)
    * Added ClaudeAgent implementation
    
    * Updated streaming logic
    
    * Small updates
    
    * Small update
    
    * Fixes
    
    * Small fix
    
    * Naming improvements
    
    * Updated imports
    
    * Addressed comments
    
    * Updated package versions
  • Python: added generic types to ChatOptions and ChatResponse/AgentResponse for Response Format (#3305)
    * added generic types to ChatOptions and ChatResponse/AgentResponse for response format
    
    * fix typevar import
    
    * fix for older python versions
    
    * fix missing import
    
    * fixed imports
    
    * fixed mypy
    
    * mypy fix
  • .NET: Python: [BREAKING] Renamed Github to GitHub (#3486)
    * Renamed Github to GitHub
    
    * Small fix
    
    * Updated package versions
  • Python: [BREAKING] changed AIFunction to FunctionTool and @ai_function to @tool (#3413)
    * changed AIFunction to FunctionTool and @ai_function to @tool
    
    * test and mypy fixes
    
    * mypy fix
    
    * switch function tool to always_require
    
    * fix noop
    
    * fix github copilot imports
    
    * test fixes
    
    * fix ollama test
    
    * fixes for tests
    
    * fix tests
    
    * reverted change to always_require and extended timeout
    
    * fix test
  • Python: [BREAKING] simplify ag-ui run logic, fix mcp bugs, fix anthropic client issues in ag-ui (#3322)
    * Refactor ag-ui to simplify flow
    
    * Refactoring
    
    * Fix backend tool
    
    * Update tests
    
    * Improvements
    
    * Fix mypy
    
    * Fixes
    
    * Fix json serialize errors
  • Python: fix(ag-ui): properly handle json serialize with handoff workflows as agent (#3275)
    * fix(ag-ui): properly handle json serialize with handoff workflows as agent
    
    * Other improvements around handling non-serializable objects
  • Python: [Breaking] Simplified Content types to a single class with classmethod constructors. (#3252)
    * ported Content to a new model
    
    * fixed linting
    
    * fixes
    
    * fixed data format handling
    
    * fix for 3.10 mypy
    
    * fix
    
    * fix int test
  • Python: Update package version (#3258)
    * package version 260116
    
    * removed name tags
  • Python: (AG-UI) Support service-managed thread on AG-UI (#3136)
    * added service thread support
    
    * set service_thread_id to only supplied_thread_id
    
    * uses raw_representation to extract the conversation_id
    
    * removed accidental edit
    
    * updated test to use raw_representation
    
    * resolves copilot review feedback
    
    * revert back StubAgent, since not used
    
    * removed relative module import
    
    * removed hasattr check per PR feedback
  • Python: fix(ag-ui): add MCP tool support for AG-UI approval flows (#3212)
    * add MCP tool support for AG-UI approval flows
    
    * use attribute in place of property
  • Python: Add dependencies param to ag-ui FastAPI endpoint (#3191)
    * Add dependencies param to ag-ui FastAPI endpoint
    
    * Address Copilot feedback
  • Python: [BREAKING]: Introducing Options as TypedDict and Generic (#3140)
    * WIP typeddict for options
    
    * updated all clients and ChatAgents
    
    * updated everything
    
    * added ADR
    
    * fix mypy
    
    * proper typevar imports
    
    * fixed import
    
    * fixed other imports
    
    * slight update in the sample
    
    * updated from feedback
    
    * fixes
    
    * fixed missing covariants and test fixes
    
    * fixed typing
    
    * updated anthropic thinking config
    
    * ruff fixes
    
    * fixed int tests
    
    * fix tests and mypy
    
    * updated integration tests
    
    * updated docstring and test fix
    
    * improved options handling in obser
    
    * mypy fix
    
    * updated a host of integration tests
    
    * fix tests
    
    * bedrock fix
  • Python: [BREAKING]: removed display_name, renamed context_providers, middleware and AggregateContextProvider (#3139)
    * removed display_name, renamed context_providers, middleware and AggregateContextProvider
    
    * fixes
    
    * fixed test
    
    * testfix
    
    * removed mistakenly put back test
    
    * updated new test
    
    * rename middlewares to middleware
    
    * middleware fixes
  • Python: Add Pydantic request model and OpenAPI tags support to AG-UI FastAPI endpoint (#2522)
    * feat(ag-ui): Add Pydantic request model and OpenAPI tags support
    
    - Add AGUIRequest Pydantic model in _types.py with field descriptions
    - Update add_agent_framework_fastapi_endpoint() to accept tags parameter
    - Use AGUIRequest model for automatic validation and OpenAPI schema generation
    - Export AGUIRequest and DEFAULT_TAGS in __init__.py
    - Update test_endpoint.py to expect 422 for invalid requests
    - Add tests for OpenAPI schema, default tags, custom tags, and validation
    
    Benefits:
    - Better API documentation with complete request schema in Swagger UI
    - Automatic request validation with Pydantic
    - Organized endpoints under 'AG-UI' tag instead of 'default'
    - Improved developer experience and type safety
    
    Fixes #<issue-number>
    
    * test(ag-ui): Add test for internal error handling to achieve 100% coverage
    
    - Add test_endpoint_internal_error_handling() to cover exception handling code
    - Mock copy.deepcopy to simulate internal error during default_state processing
    - Add type: ignore for FastAPI tags parameter (known pyright compatibility issue)
    - Achieves 100% test coverage for _endpoint.py (previously missing lines 103-105)
  • fix(anthropic): fix duplicate ToolCallStartEvent in streaming tool calls (#3051)
    When processing `input_json_delta` events, the Anthropic client was
    passing the tool name from the previous `tool_use` event. This caused
    ag-ui's `_handle_function_call_content` to emit a `ToolCallStartEvent`
    for every streaming chunk (since it triggers on `if content.name:`).
    
    This fix changes the behavior to pass an empty string for `name` in
    `input_json_delta` events, matching OpenAI's behavior where streaming
    argument chunks have `name=""`. The initial `tool_use` event still
    provides the tool name, so only one `ToolCallStartEvent` is emitted.
    
    Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com>
  • Python: Fix AzureAIClient tool call bug for AG-UI use (#3148)
    * Fiz AzureAIClient tool call bug
    
    * Address copilot feedback
  • Python: fix(ag-ui): Execute tools with approval_mode, fix shared state, code cleanup (#3079)
    * fix(ag-ui): execute tools after approval in human-in-the-loop flow
    
    * Fix shared state bug
    
    * Bug fix finalized
    
    * Refactoring to clean up code
    
    * Code cleanup
    
    * More fixes
    
    * More code cleanup
    
    * Add version detection in __init__.py to ruff ignore list
  • Python: Bump python version to 1.0.0b260107 for a release (#3128)
    * Bump python version to 1.0.0b260107 for a release
    
    * Update changelog
  • Python: Fix MCP tool result serialization for list[TextContent] (#2523)
    * Fix MCP tool result serialization for list[TextContent]
    
    When MCP tools return results containing list[TextContent], they were
    incorrectly serialized to object repr strings like:
    '[<agent_framework._types.TextContent object at 0x...>]'
    
    This fix properly extracts text content from list items by:
    1. Checking if items have a 'text' attribute (TextContent)
    2. Using model_dump() for items that support it
    3. Falling back to str() for other types
    4. Joining single items as plain text, multiple items as JSON array
    
    Fixes #2509
    
    * Address PR review feedback for MCP tool result serialization
    
    - Extract serialize_content_result() to shared _utils.py
    - Fix logic: use texts[0] instead of join for single item
    - Add type annotation: texts: list[str] = []
    - Return empty string for empty list instead of '[]'
    - Move import json to file top level
    - Add comprehensive unit tests for serialization
    
    * Address PR review feedback: fix type checking and double serialization
    
    - Add isinstance(item.text, str) check to ensure text attribute is a string
    - Fix double-serialization issue by keeping model_dump results as dicts
      until final json.dumps (removes escaped JSON strings in arrays)
    - Improve docstring with detailed return value documentation
    - Add test for non-string text attribute handling
    - Add tests for list type tool results in _events.py path
    
    * Simplify PR: minimal changes to fix MCP tool result serialization
    
    Addresses reviewer feedback about excessive refactoring:
    - Reset _events.py to original structure
    - Only add import and use serialize_content_result in one location
    - All review comments addressed in serialize_content_result():
      - Added isinstance(item.text, str) check
      - Use model_dump(mode="json") to avoid double-serialization
      - Improved docstring with explicit return value documentation
      - Empty list returns "" instead of "[]"
    
    * Refactor: Move MCP TextContent serialization to core prepare_function_call_results
    
    Per reviewer feedback, moved the TextContent serialization logic from
    ag-ui's serialize_content_result to the core package's
    prepare_function_call_results function.
    
    Changes:
    - Added handling for objects with 'text' attribute (like MCP TextContent)
      in _prepare_function_call_results_as_dumpable
    - Removed serialize_content_result from ag-ui/_utils.py
    - Updated _events.py and _message_adapters.py to use
      prepare_function_call_results from core package
    - Updated tests to match the core function's behavior
    
    * Fix failing tests for prepare_function_call_results behavior
    
    - test_tool_result_with_none: Update expected value to 'null' (JSON serialization of None)
    - test_tool_result_with_model_dump_objects: Use Pydantic BaseModel instead of plain class
    
    * Fix B903 linter error: Convert MockTextContent to dataclass
    
    The ruff linter was reporting B903 (class could be dataclass or namedtuple)
    for the MockTextContent test helper classes. This commit converts them to
    dataclasses to satisfy the linter check.
  • Python: Updated package versions (#3024)
    * Updated package versions
    
    * Updated changelog
  • Python: Bump Py version to 1.0.0b251218 for a release. Update CHANGELOG (#2968)
    * Bump Py version to 1.0.0b251218 for a release. Update CHANGELOG
    
    * update lock
    
    * Fix formatting
    
    * Fix ChatKit typing
  • Python: Fixes Run ID and Thread ID casing to align with AG-UI Typescript SDK (#2948)
    * added camelCase input to run id and thread id aligning with @ag-ui/core
    
    * fixed per copilot suggestions
  • Python: [BREAKING] Observability updates (#2782)
    * fixes Python: Add env_file_path parameter to setup_observability() similar to AzureOpenAIChatClient
    Fixes #2186
    
    * WIP on updates using configure_azure_monitor
    
    * improved setup and clarity
    
    * fixed root .env.example
    
    * revert changes
    
    * updated files
    
    * updated sample
    
    * updated zero code
    
    * test fixes and fixed links
    
    * fix devui
    
    * removed planning docs
    
    * added enable method and updated readme and samples
    
    * clarified docstring
    
    * add return annotation
    
    * updated naming
    
    * update capatilized version
    
    * updated readme and some fixes
    
    * updated decorator name inline with the rest
    
    * feedback from comments addressed
  • Python: Updated package versions (#2784)
    * Updated package versions
    
    * Small fix
  • Python: Updated package versions (#2737)
    * Updated package versions
    
    * Updated changelog
  • Python: Fixed empty text content pydantic validation failure (#2539)
    * Fixed empty text content pydantic validation failure
    
    * simplify syntax. renamed test
    
    ---------
    
    Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com>
  • Python: Refactor ag-ui to clean up some patterns (#2363)
    * Refactor ag-ui to clean up some patterns
    
    * Mypy fixes
    
    * Fix imports, typing, tests, logging.
    
    * Fix test import error
    
    * Fix imports again
    
    * Fix thread handling
  • Python: clean up exception (#2319)
    * 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>
  • Python: Clean up imports (#2318)
    * chore: tidy imports
    
    * Update python/packages/azurefunctions/agent_framework_azurefunctions/_errors.py
    
    Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
    
    * Update python/packages/azurefunctions/agent_framework_azurefunctions/_callbacks.py
    
    Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
    
    * chore: revert stub file change
    
    * chore: trigger pre-commit hook, re-add `annotations` import
    
    ---------
    
    Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
  • Python: Introducing support for declarative yaml spec (#2002)
    * 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
  • Python: Fix ag-ui state handling issues (#2289)
    * Fix ag-ui state handling
    
    * Bump package version and update changelog
    
    * Update changelog
  • Python: Updated package versions (#2238)
    * Updated package versions
    
    * Small fix
    
    * Small fix
  • Python: fix tool call id mismatch in ag-ui (#2166)
    * Fix state for pending requests bug
    
    * Bump ver
    
    * Update changelog
  • Python: Fix ag-ui regressions (#2114)
    * Bump ag-ui package version. Update CHANGELOG
    
    * Fix ag-ui bugs
    
    * Revert port test change
    
    * Cleanup
    
    * Intro factory funcs for samples
    
    * Revert package ver change
  • Python: Add concrete AGUIChatClient (#2072)
    * Add concrete AGUIChatClient
    
    * Update logging docstrings and conventions
    
    * PR feedback
    
    * Updates to support client-side tool calls
  • Python: Fix ag-ui examples packaging for PyPI publish (#1953)
    * Fix ag-ui examples packaging for PyPI publish
    
    * Fix markdown links