X Tutup
Skip to content

feat(pydantic-ai): Add tool description to execute_tool spans#5596

Merged
ericapisani merged 27 commits intomasterfrom
ep/add-tool-description-to-pydantic-ai-spans
Mar 9, 2026
Merged

feat(pydantic-ai): Add tool description to execute_tool spans#5596
ericapisani merged 27 commits intomasterfrom
ep/add-tool-description-to-pydantic-ai-spans

Conversation

@ericapisani
Copy link
Member

@ericapisani ericapisani commented Mar 5, 2026

Add the tool's description to gen_ai.execute_tool spans via the gen_ai.tool.description span data attribute.

When a pydantic-ai tool is defined with a docstring, that docstring becomes the tool's description in its ToolDefinition. This PR surfaces that description in the corresponding Sentry span, making it easier to understand what each tool does when inspecting traces.

The description is sourced from tool.tool_def.description on the internal tool object. If no description is available (e.g. the tool has no docstring), the attribute value is None.

Include the tool's description (from its docstring) in gen_ai.execute_tool
spans via the gen_ai.tool.description span data attribute. The description
is sourced from the tool's ToolDefinition, which is derived from the
tool's docstring.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (pydantic-ai) Add tool description to execute_tool spans by ericapisani in #5596

Bug Fixes 🐛

  • (celery) Propagate user-set headers by sentrivana in #5581
  • (utils) Avoid double serialization of strings in safe_serialize by ericapisani in #5587

Documentation 📚

  • (openai-agents) Remove inapplicable comment by alexander-alderman-webb in #5495
  • Add AGENTS.md by sentrivana in #5579
  • Add set_attribute example to changelog by sentrivana in #5578

Internal Changes 🔧

Openai Agents

  • Replace mocks with httpx in MCP tool tests by alexander-alderman-webb in #5605
  • Replace mocks with httpx in handoff tests by alexander-alderman-webb in #5604
  • Replace mocks with httpx in API error test by alexander-alderman-webb in #5601
  • Replace mocks with httpx in non-error single-response tests by alexander-alderman-webb in #5600
  • Remove test for unreachable state by alexander-alderman-webb in #5584
  • Expect namespace tool field for new openai versions by alexander-alderman-webb in #5599

Other

  • Do not run actions on potel-base by sentrivana in #5614

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Codecov Results 📊

13 passed | Total: 13 | Pass Rate: 100% | Execution Time: 7.66s

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

❌ Patch coverage is 0.00%. Project has 13870 uncovered lines.
✅ Project coverage is 30.72%. Comparing base (base) to head (head).

Files with missing lines (2)
File Patch % Lines
tools.py 0.00% ⚠️ 90 Missing
execute_tool.py 0.00% ⚠️ 22 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    25.63%    30.72%    +5.09%
==========================================
  Files          189       189         —
  Lines        20016     20020        +4
  Branches      6476      6478        +2
==========================================
+ Hits          5131      6150     +1019
- Misses       14885     13870     -1015
- Partials       421       468       +47

Generated by Codecov Action

ericapisani and others added 4 commits March 6, 2026 07:42
Move Optional inside quotes for consistency with type annotation
style conventions.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
….com:getsentry/sentry-python into ep/add-tool-description-to-pydantic-ai-spans
When a tool has no description, the tool_description field should be
present in the span data but have a None value. Update the assertion
to check for field presence rather than field absence.

Also use `is None` instead of `== None` for proper Python style.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@ericapisani ericapisani marked this pull request as ready for review March 6, 2026 14:31
@ericapisani ericapisani requested a review from a team as a code owner March 6, 2026 14:31
Use getattr with a None default when accessing tool_definition.description
to prevent AttributeError if the attribute is missing.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Copy link
Contributor

@alexander-alderman-webb alexander-alderman-webb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice work! See the two comments I've left.

I know there are plenty of existing pydantic-ai tests calling execute_tool_span() as if it's part of the public API we offer. I don't believe it's intended for users to call these functions directly however. As such, they are considered private.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Autofix Details

Bugbot Autofix prepared fixes for both issues found in the latest run.

  • ✅ Fixed: Unused ToolDefinition import in test file
    • Removed the unused import of ToolDefinition from pydantic_ai._tool_manager at line 21 of the test file.
  • ✅ Fixed: Test name contradicts its actual assertion behavior
    • Updated the test to check that GEN_AI_TOOL_DESCRIPTION is not present when a tool has no description, and modified execute_tool_span to only set the description field when it's truthy (not empty string or None).

Create PR

Or push these changes by commenting:

@cursor push 553b8a869b
Preview (553b8a869b)
diff --git a/sentry_sdk/integrations/pydantic_ai/spans/execute_tool.py b/sentry_sdk/integrations/pydantic_ai/spans/execute_tool.py
--- a/sentry_sdk/integrations/pydantic_ai/spans/execute_tool.py
+++ b/sentry_sdk/integrations/pydantic_ai/spans/execute_tool.py
@@ -39,10 +39,9 @@
     span.set_data(SPANDATA.GEN_AI_TOOL_NAME, tool_name)
 
     if tool_definition is not None:
-        span.set_data(
-            SPANDATA.GEN_AI_TOOL_DESCRIPTION,
-            getattr(tool_definition, "description", None),
-        )
+        description = getattr(tool_definition, "description", None)
+        if description:
+            span.set_data(SPANDATA.GEN_AI_TOOL_DESCRIPTION, description)
 
     _set_agent_data(span, agent)
 

diff --git a/tests/integrations/pydantic_ai/test_pydantic_ai.py b/tests/integrations/pydantic_ai/test_pydantic_ai.py
--- a/tests/integrations/pydantic_ai/test_pydantic_ai.py
+++ b/tests/integrations/pydantic_ai/test_pydantic_ai.py
@@ -18,7 +18,6 @@
 from pydantic_ai.messages import BinaryContent, UserPromptPart
 from pydantic_ai.usage import RequestUsage
 from pydantic_ai.exceptions import ModelRetry, UnexpectedModelBehavior
-from pydantic_ai._tool_manager import ToolDefinition
 
 
 @pytest.fixture
@@ -2867,5 +2866,4 @@
 
     tool_span = tool_spans[0]
     assert tool_span["data"]["gen_ai.tool.name"] == "no_docs_tool"
-    assert SPANDATA.GEN_AI_TOOL_DESCRIPTION in tool_span["data"]
-    assert tool_span["data"][SPANDATA.GEN_AI_TOOL_DESCRIPTION] is None
+    assert SPANDATA.GEN_AI_TOOL_DESCRIPTION not in tool_span["data"]

diff --git a/tox.venv/bin/Activate.ps1 b/tox.venv/bin/Activate.ps1
new file mode 100644
--- /dev/null
+++ b/tox.venv/bin/Activate.ps1
@@ -1,0 +1,247 @@
+<#
+.Synopsis
+Activate a Python virtual environment for the current PowerShell session.
+
+.Description
+Pushes the python executable for a virtual environment to the front of the
+$Env:PATH environment variable and sets the prompt to signify that you are
+in a Python virtual environment. Makes use of the command line switches as
+well as the `pyvenv.cfg` file values present in the virtual environment.
+
+.Parameter VenvDir
+Path to the directory that contains the virtual environment to activate. The
+default value for this is the parent of the directory that the Activate.ps1
+script is located within.
+
+.Parameter Prompt
+The prompt prefix to display when this virtual environment is activated. By
+default, this prompt is the name of the virtual environment folder (VenvDir)
+surrounded by parentheses and followed by a single space (ie. '(.venv) ').
+
+.Example
+Activate.ps1
+Activates the Python virtual environment that contains the Activate.ps1 script.
+
+.Example
+Activate.ps1 -Verbose
+Activates the Python virtual environment that contains the Activate.ps1 script,
+and shows extra information about the activation as it executes.
+
+.Example
+Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv
+Activates the Python virtual environment located in the specified location.
+
+.Example
+Activate.ps1 -Prompt "MyPython"
+Activates the Python virtual environment that contains the Activate.ps1 script,
+and prefixes the current prompt with the specified string (surrounded in
+parentheses) while the virtual environment is active.
+
+.Notes
+On Windows, it may be required to enable this Activate.ps1 script by setting the
+execution policy for the user. You can do this by issuing the following PowerShell
+command:
+
+PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
+
+For more information on Execution Policies: 
+https://go.microsoft.com/fwlink/?LinkID=135170
+
+#>
+Param(
+    [Parameter(Mandatory = $false)]
+    [String]
+    $VenvDir,
+    [Parameter(Mandatory = $false)]
+    [String]
+    $Prompt
+)
+
+<# Function declarations --------------------------------------------------- #>
+
+<#
+.Synopsis
+Remove all shell session elements added by the Activate script, including the
+addition of the virtual environment's Python executable from the beginning of
+the PATH variable.
+
+.Parameter NonDestructive
+If present, do not remove this function from the global namespace for the
+session.
+
+#>
+function global:deactivate ([switch]$NonDestructive) {
+    # Revert to original values
+
+    # The prior prompt:
+    if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) {
+        Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt
+        Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT
+    }
+
+    # The prior PYTHONHOME:
+    if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) {
+        Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME
+        Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME
+    }
+
+    # The prior PATH:
+    if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) {
+        Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH
+        Remove-Item -Path Env:_OLD_VIRTUAL_PATH
+    }
+
+    # Just remove the VIRTUAL_ENV altogether:
+    if (Test-Path -Path Env:VIRTUAL_ENV) {
+        Remove-Item -Path env:VIRTUAL_ENV
+    }
+
+    # Just remove VIRTUAL_ENV_PROMPT altogether.
+    if (Test-Path -Path Env:VIRTUAL_ENV_PROMPT) {
+        Remove-Item -Path env:VIRTUAL_ENV_PROMPT
+    }
+
+    # Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether:
+    if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) {
+        Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force
+    }
+
+    # Leave deactivate function in the global namespace if requested:
+    if (-not $NonDestructive) {
+        Remove-Item -Path function:deactivate
+    }
+}
+
+<#
+.Description
+Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the
+given folder, and returns them in a map.
+
+For each line in the pyvenv.cfg file, if that line can be parsed into exactly
+two strings separated by `=` (with any amount of whitespace surrounding the =)
+then it is considered a `key = value` line. The left hand string is the key,
+the right hand is the value.
+
+If the value starts with a `'` or a `"` then the first and last character is
+stripped from the value before being captured.
+
+.Parameter ConfigDir
+Path to the directory that contains the `pyvenv.cfg` file.
+#>
+function Get-PyVenvConfig(
+    [String]
+    $ConfigDir
+) {
+    Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg"
+
+    # Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue).
+    $pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue
+
+    # An empty map will be returned if no config file is found.
+    $pyvenvConfig = @{ }
+
+    if ($pyvenvConfigPath) {
+
+        Write-Verbose "File exists, parse `key = value` lines"
+        $pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath
+
+        $pyvenvConfigContent | ForEach-Object {
+            $keyval = $PSItem -split "\s*=\s*", 2
+            if ($keyval[0] -and $keyval[1]) {
+                $val = $keyval[1]
+
+                # Remove extraneous quotations around a string value.
+                if ("'""".Contains($val.Substring(0, 1))) {
+                    $val = $val.Substring(1, $val.Length - 2)
+                }
+
+                $pyvenvConfig[$keyval[0]] = $val
+                Write-Verbose "Adding Key: '$($keyval[0])'='$val'"
+            }
+        }
+    }
+    return $pyvenvConfig
+}
+
+
+<# Begin Activate script --------------------------------------------------- #>
+
+# Determine the containing directory of this script
+$VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
+$VenvExecDir = Get-Item -Path $VenvExecPath
+
+Write-Verbose "Activation script is located in path: '$VenvExecPath'"
+Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)"
+Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)"
+
+# Set values required in priority: CmdLine, ConfigFile, Default
+# First, get the location of the virtual environment, it might not be
+# VenvExecDir if specified on the command line.
+if ($VenvDir) {
+    Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values"
+}
+else {
+    Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir."
+    $VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/")
+    Write-Verbose "VenvDir=$VenvDir"
+}
+
+# Next, read the `pyvenv.cfg` file to determine any required value such
+# as `prompt`.
+$pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir
+
+# Next, set the prompt from the command line, or the config file, or
+# just use the name of the virtual environment folder.
+if ($Prompt) {
+    Write-Verbose "Prompt specified as argument, using '$Prompt'"
+}
+else {
+    Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value"
+    if ($pyvenvCfg -and $pyvenvCfg['prompt']) {
+        Write-Verbose "  Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'"
+        $Prompt = $pyvenvCfg['prompt'];
+    }
+    else {
+        Write-Verbose "  Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virtual environment)"
+        Write-Verbose "  Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'"
+        $Prompt = Split-Path -Path $venvDir -Leaf
+    }
+}
+
+Write-Verbose "Prompt = '$Prompt'"
+Write-Verbose "VenvDir='$VenvDir'"
+
+# Deactivate any currently active virtual environment, but leave the
+# deactivate function in place.
+deactivate -nondestructive
+
+# Now set the environment variable VIRTUAL_ENV, used by many tools to determine
+# that there is an activated venv.
+$env:VIRTUAL_ENV = $VenvDir
+
+if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {
+
+    Write-Verbose "Setting prompt to '$Prompt'"
+
+    # Set the prompt to include the env name
+    # Make sure _OLD_VIRTUAL_PROMPT is global
+    function global:_OLD_VIRTUAL_PROMPT { "" }
+    Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT
+    New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt
+
+    function global:prompt {
+        Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) "
+        _OLD_VIRTUAL_PROMPT
+    }
+    $env:VIRTUAL_ENV_PROMPT = $Prompt
+}
+
+# Clear PYTHONHOME
+if (Test-Path -Path Env:PYTHONHOME) {
+    Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME
+    Remove-Item -Path Env:PYTHONHOME
+}
+
+# Add the venv to the PATH
+Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH
+$Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH"

diff --git a/tox.venv/bin/activate b/tox.venv/bin/activate
new file mode 100644
--- /dev/null
+++ b/tox.venv/bin/activate
@@ -1,0 +1,70 @@
+# This file must be used with "source bin/activate" *from bash*
+# You cannot run it directly
+
+deactivate () {
+    # reset old environment variables
+    if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
+        PATH="${_OLD_VIRTUAL_PATH:-}"
+        export PATH
+        unset _OLD_VIRTUAL_PATH
+    fi
+    if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
+        PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
+        export PYTHONHOME
+        unset _OLD_VIRTUAL_PYTHONHOME
+    fi
+
+    # Call hash to forget past commands. Without forgetting
+    # past commands the $PATH changes we made may not be respected
+    hash -r 2> /dev/null
+
+    if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
+        PS1="${_OLD_VIRTUAL_PS1:-}"
+        export PS1
+        unset _OLD_VIRTUAL_PS1
+    fi
+
+    unset VIRTUAL_ENV
+    unset VIRTUAL_ENV_PROMPT
+    if [ ! "${1:-}" = "nondestructive" ] ; then
+    # Self destruct!
+        unset -f deactivate
+    fi
+}
+
+# unset irrelevant variables
+deactivate nondestructive
+
+# on Windows, a path can contain colons and backslashes and has to be converted:
+if [ "${OSTYPE:-}" = "cygwin" ] || [ "${OSTYPE:-}" = "msys" ] ; then
+    # transform D:\path\to\venv to /d/path/to/venv on MSYS
+    # and to /cygdrive/d/path/to/venv on Cygwin
+    export VIRTUAL_ENV=$(cygpath /workspace/tox.venv)
+else
+    # use the path as-is
+    export VIRTUAL_ENV=/workspace/tox.venv
+fi
+
+_OLD_VIRTUAL_PATH="$PATH"
+PATH="$VIRTUAL_ENV/"bin":$PATH"
+export PATH
+
+# unset PYTHONHOME if set
+# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
+# could use `if (set -u; : $PYTHONHOME) ;` in bash
+if [ -n "${PYTHONHOME:-}" ] ; then
+    _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
+    unset PYTHONHOME
+fi
+
+if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
+    _OLD_VIRTUAL_PS1="${PS1:-}"
+    PS1='(tox.venv) '"${PS1:-}"
+    export PS1
+    VIRTUAL_ENV_PROMPT='(tox.venv) '
+    export VIRTUAL_ENV_PROMPT
+fi
+
+# Call hash to forget past commands. Without forgetting
+# past commands the $PATH changes we made may not be respected
+hash -r 2> /dev/null

diff --git a/tox.venv/bin/activate.csh b/tox.venv/bin/activate.csh
new file mode 100644
--- /dev/null
+++ b/tox.venv/bin/activate.csh
@@ -1,0 +1,27 @@
+# This file must be used with "source bin/activate.csh" *from csh*.
+# You cannot run it directly.
+
+# Created by Davide Di Blasi <davidedb@gmail.com>.
+# Ported to Python 3.3 venv by Andrew Svetlov <andrew.svetlov@gmail.com>
+
+alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; unsetenv VIRTUAL_ENV_PROMPT; test "\!:*" != "nondestructive" && unalias deactivate'
+
+# Unset irrelevant variables.
+deactivate nondestructive
+
+setenv VIRTUAL_ENV /workspace/tox.venv
+
+set _OLD_VIRTUAL_PATH="$PATH"
+setenv PATH "$VIRTUAL_ENV/"bin":$PATH"
+
+
+set _OLD_VIRTUAL_PROMPT="$prompt"
+
+if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
+    set prompt = '(tox.venv) '"$prompt"
+    setenv VIRTUAL_ENV_PROMPT '(tox.venv) '
+endif
+
+alias pydoc python -m pydoc
+
+rehash

diff --git a/tox.venv/bin/activate.fish b/tox.venv/bin/activate.fish
new file mode 100644
--- /dev/null
+++ b/tox.venv/bin/activate.fish
@@ -1,0 +1,69 @@
+# This file must be used with "source <venv>/bin/activate.fish" *from fish*
+# (https://fishshell.com/). You cannot run it directly.
+
+function deactivate  -d "Exit virtual environment and return to normal shell environment"
+    # reset old environment variables
+    if test -n "$_OLD_VIRTUAL_PATH"
+        set -gx PATH $_OLD_VIRTUAL_PATH
+        set -e _OLD_VIRTUAL_PATH
+    end
+    if test -n "$_OLD_VIRTUAL_PYTHONHOME"
+        set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
+        set -e _OLD_VIRTUAL_PYTHONHOME
+    end
+
+    if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
+        set -e _OLD_FISH_PROMPT_OVERRIDE
+        # prevents error when using nested fish instances (Issue #93858)
+        if functions -q _old_fish_prompt
+            functions -e fish_prompt
+            functions -c _old_fish_prompt fish_prompt
+            functions -e _old_fish_prompt
+        end
+    end
+
+    set -e VIRTUAL_ENV
+    set -e VIRTUAL_ENV_PROMPT
+    if test "$argv[1]" != "nondestructive"
+        # Self-destruct!
+        functions -e deactivate
+    end
+end
+
+# Unset irrelevant variables.
+deactivate nondestructive
+
+set -gx VIRTUAL_ENV /workspace/tox.venv
+
+set -gx _OLD_VIRTUAL_PATH $PATH
+set -gx PATH "$VIRTUAL_ENV/"bin $PATH
+
+# Unset PYTHONHOME if set.
+if set -q PYTHONHOME
+    set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
+    set -e PYTHONHOME
+end
+
+if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
+    # fish uses a function instead of an env var to generate the prompt.
+
+    # Save the current fish_prompt function as the function _old_fish_prompt.
+    functions -c fish_prompt _old_fish_prompt
+
+    # With the original prompt function renamed, we can override with our own.
+    function fish_prompt
+        # Save the return status of the last command.
+        set -l old_status $status
+
+        # Output the venv prompt; color taken from the blue of the Python logo.
+        printf "%s%s%s" (set_color 4B8BBE) '(tox.venv) ' (set_color normal)
+
+        # Restore the return status of the previous command.
+        echo "exit $old_status" | .
+        # Output the original/"old" prompt.
+        _old_fish_prompt
+    end
+
+    set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
+    set -gx VIRTUAL_ENV_PROMPT '(tox.venv) '
+end

diff --git a/tox.venv/bin/pip b/tox.venv/bin/pip
new file mode 100644
--- /dev/null
+++ b/tox.venv/bin/pip
@@ -1,0 +1,8 @@
+#!/workspace/tox.venv/bin/python3
+# -*- coding: utf-8 -*-
+import re
+import sys
+from pip._internal.cli.main import main
+if __name__ == '__main__':
+    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
+    sys.exit(main())

diff --git a/tox.venv/bin/pip3 b/tox.venv/bin/pip3
new file mode 100644
--- /dev/null
+++ b/tox.venv/bin/pip3
@@ -1,0 +1,8 @@
+#!/workspace/tox.venv/bin/python3
+# -*- coding: utf-8 -*-
+import re
+import sys
+from pip._internal.cli.main import main
+if __name__ == '__main__':
+    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
+    sys.exit(main())

diff --git a/tox.venv/bin/pip3.12 b/tox.venv/bin/pip3.12
new file mode 100644
--- /dev/null
+++ b/tox.venv/bin/pip3.12
@@ -1,0 +1,8 @@
+#!/workspace/tox.venv/bin/python3
+# -*- coding: utf-8 -*-
+import re
+import sys
+from pip._internal.cli.main import main
+if __name__ == '__main__':
+    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
+    sys.exit(main())

diff --git a/tox.venv/bin/python b/tox.venv/bin/python
new file mode 100644
--- /dev/null
+++ b/tox.venv/bin/python
@@ -1,0 +1 @@
+python3
\ No newline at end of file

diff --git a/tox.venv/bin/python3 b/tox.venv/bin/python3
new file mode 100644
--- /dev/null
+++ b/tox.venv/bin/python3
@@ -1,0 +1 @@
+/usr/bin/python3
\ No newline at end of file

diff --git a/tox.venv/bin/python3.12 b/tox.venv/bin/python3.12
new file mode 100644
--- /dev/null
+++ b/tox.venv/bin/python3.12
@@ -1,0 +1 @@
+python3
\ No newline at end of file

diff --git a/tox.venv/bin/ruff b/tox.venv/bin/ruff
new file mode 100644
--- /dev/null
+++ b/tox.venv/bin/ruff
@@ -1,0 +1,79791 @@
+�ELF��������������>�������l�����@�������������������@�8��@�!� ���������@�������@�������@�������������������������������������������������������������������������������������������������������������������������l�������l�����������������������l�������l�������l�����`S.�����`S.���������������������0X������0x������0x���������������������������������������i������ș������ș�������2�������� ���������������������0X������0x������0x���������������������������������������`������؀������؀������������������������������R�td����0X������0x������0x������������������������������P�td�����IS������IS������IS�����ܿ������ܿ��������������Q�td������������������������������������������������������������������������������������D�������D���������������/lib64/ld-linux-x86-64.so.2�������������GNU������������� ���������������GNU���$&�������S�Ȱ"j������������������������������������������������������ �������������������"��� �������������������>��� �������������������X���"�������������������g�����������������������v�����������������������}�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
+�����������������������������������������������/�����������������������>�����������������������O�����������������������Y�����������������������_�����������������������g�����������������������u�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������&�����������������������;�����������������������A�����������������������K�����������������������Q�����������������������W�����������������������_�����������������������e�����������������������l�����������������������w�����������������������������������������������������������������������������������������������������������������������������������������������������������������������
+��� �������������������������������������������#�����������������������*�����������������������8�����������������������H�����������������������O�����������������������V�����������������������_�����������������������d��� �������������������j�����������������������s��� �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������#�����������������������,�����������������������:�����������������������A�����������������������J�����������������������S�����������������������]�����������������������f�����������������������n��� �������������������x��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� ����������������������� �������������������������������������������*�����������������������5�����������������������:�����������������������B�����������������������G��� �������������������l��� �������������������������������������������������������������������������������������������������������������������������������������������������������������������5�����������������������A�����������������������K�����������������������i�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������$�����������������������+�����������������������9�����������������������O�����������������������d�����������������������u�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������'�����������������������/�����������������������B�����������������������Y�����������������������s���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������	�
+
+��������������������������������������������������������
�������������������������������������������������������������������������������������������������������������������������������������������������
�
�����������������������������������������������������������
+����������������	��`�����������(	��������������?	��������������f	��������������p	�������������{	����������P&y������	������S&y���
��	������``'	����	������u�i	����3	������u�i	����3	������r�i	����O	��������������[	������u�i	����3	������u�i	����3	������u�i	����3	�������ii
�����	������r�i	��
+�O	������t�i	�����	�������ii
�����	�������ii
�����	�������ii
��	��	�������ii
�����	���������������	���������������	���������������	���������������	�����������������������������������__libc_start_main�__gmon_start__�_ITM_deregisterTMCloneTable�_ITM_registerTMCloneTable�__cxa_finalize�_Unwind_Resume�memcpy�memset�memcmp�memmove�bcmp�close�read�__errno_location�isatty�syscall�strlen�tcgetattr�tcsetattr�nanosleep�sched_yield�write�open�poll�dlsym�pthread_join�_Unwind_DeleteException�pthread_detach�inotify_rm_watch�readdir64�dirfd�pread64�inotify_init1�epoll_create1�eventfd�epoll_ctl�epoll_wait�inotify_add_watch�_Unwind_RaiseException�writev�fcntl�open64�dup�signal�sysconf�pthread_self�pthread_getattr_np�pthread_attr_getstack�pthread_attr_destroy�abort�sigaction�pause�log10�lseek64�ioctl�getuid�getpwuid_r�_Unwind_GetLanguageSpecificData�_Unwind_GetIPInfo�_Unwind_GetRegionStart�_Unwind_SetGR�_Unwind_SetIP�_Unwind_GetTextRelBase�_Unwind_GetDataRelBase�gettid�_Unwind_Backtrace�getcwd�_Unwind_GetIP�dl_iterate_phdr�munmap�mmap64�realpath�free�statx�readlink�__cxa_thread_atexit_impl�pthread_key_create�pthread_key_delete�pthread_setspecific�realloc�malloc�getenv�mkdir�__xpg_strerror_r�pthread_attr_getguardsize�sigaltstack�getauxval�mprotect�clock_gettime�unlink�openat64�unlinkat�fdopendir�closedir�opendir�getrandom�pthread_attr_init�pthread_attr_setstacksize�pthread_create�pthread_setname_np�sched_getaffinity�exit�waitid�waitpid�environ�getpid�pidfd_getpid�pidfd_spawnp�gnu_get_libc_version�socketpair�fork�recvmsg�recv�posix_spawn_file_actions_addchdir_np�posix_spawn_file_actions_addchdir�posix_spawnattr_init�posix_spawn_file_actions_init�posix_spawn_file_actions_adddup2�posix_spawnattr_setpgroup�posix_spawn_file_actions_destroy�posix_spawnattr_destroy�sigemptyset�sigaddset�posix_spawnattr_setsigdefault�posix_spawnattr_setflags�_exit�posix_spawnp�dup2�setgroups�setgid�setuid�chroot�chdir�setpgid�setsid�execvp�sendmsg�pipe2�_Unwind_GetCFA�_Unwind_FindEnclosingFunction�logf�strchr�strncmp�strcmp�secure_getenv�pthread_mutex_trylock�pthread_mutex_unlock�__sched_cpucount�sched_getcpu�pthread_cond_signal�gettimeofday�pthread_cond_timedwait�pthread_cond_wait�sched_setaffinity�sigfillset�pthread_sigmask�pthread_cond_init�__rawmemchr�sbrk�strerror_r�strncpy�pthread_mutex_lock�pthread_mutexattr_init�pthread_mutexattr_settype�pthread_mutex_init�pthread_mutexattr_destroy�mmap�madvise�memchr�__register_atfork�__fxstatat64�__cxa_atexit�__fxstat64�__lxstat64�__xstat64�libgcc_s.so.1�GCC_3.0�GCC_3.3�GCC_4.2.0�librt.so.1�GLIBC_2.2.5�libpthread.so.0�GLIBC_2.3.2�GLIBC_2.12�libm.so.6�libdl.so.2�libc.so.6�GLIBC_2.3�GLIBC_2.3.4�GLIBC_2.4�GLIBC_2.6�GLIBC_2.7�GLIBC_2.9�GLIBC_2.14�GLIBC_2.15�GLIBC_2.16�GLIBC_2.17������`���������������`�������h���������������ј�����������������������?l����������������������Al���������������������@Bl���������������������@Wl���������������������PYl�����ȃ���������������Zl�����Ѓ���������������ol�����胚��������������ql����������������������rl�����������������������l�����������������������l�����������������������l����� ���������������аl�����8����������������l�����@���������������гl�����H���������������p�l�����`�����������������l�����h�����������������l�����p�����������������m�����������������������m�����������������������m���������������������pBm����������������������Dm����������������������Em����������������������fm�����؄���������������gm���������������������Phm�����脚������������� ym���������������������0zm����������������������zm���������������������p�m�����(�����������������m�����0���������������0�m�����8�����������������m�����P�����������������m�����X���������������`�m�����`�����������������������x����������������������������������������������������������������������������������������=l�����؅���������������:o����������������������=l����������������������;o�����������������������������������������������������0�����������������������H�����������������������`�����������������������x�����������������������������������������������������������������������������������������������؆���������������������������������������������������������������������� �����������������������8�����������������������P�����������������������h�����������������������������������������������������������������������������������������������ȇ����������������������������������������������������������������������������������������������(�����������������������@�����������������������X�����������������������p�����������������������������������������������������������������������������������������������Ј����������������������舚���������������������������������������������������������������������0�����������������������H�����������������������`�����������������������x�����������������������������������������������������������������������������������������������؉���������������������������������������������������������������������� �����������������������8�����������������������P�����������������������h�����������������������������������������������������������������������������������������������Ȋ����������������������������������������������������������������������������������������������(�����������������������@�����������������������X�����������������������p���������������q�������������������������m���������������������0�m�����ȋ��������������A�����������������������A�����������������������A�����������������������A�������(���������������A�������@���������������A�������X���������������A�������p���������������A�����������������������A�����������������������A�����������������������A�������Ќ��������������A�������茚�������������A�����������������������A�����������������������A�������0���������������A�������H���������������A�������`���������������A�������x���������������A�����������������������A�����������������������A�����������������������A�������؍��������������A�����������������������A�����������������������A������� ���������������A�������8���������������A�������P���������������A�������h���������������A�����������������������A�����������������������A�����������������������A�������Ȏ��������������A�����������������������A�����������������������A�����������������������A�������(���������������BU������@���������������BU������X���������������BU������p���������������BU����������������������BU����������������������BU����������������������BU������Џ��������������BU������菚�������������BU����������������������BU����������������������BU������0���������������BU������H���������������BU������`���������������BU������x���������������BU����������������������BU����������������������BU����������������������BU������ؐ��������������BU��������������������BU����������������������BU������ ���������������BU������8���������������BU������P���������������BU������h���������������BU����������������������BU����������������������BU����������������������BU������ȑ��������������BU����������������������BU����������������������BU����������������������BU������(���������������BU������X���������������0�m�����`���������������BU������x���������������BU����������������������BU����������������������d&����������������������d&������ؒ�������������������������������������������������������������������� �����������������������8�����������������������P�����������������n�����h����������������9o�����p����������������C�����������������������C�����������������������C�����������������������C������Г���������������C������蓚��������������C�����������������������C�����������������������C������0����������������C������H���������������P�n�����`�����������������n�����h�����������������n�����p����������������C������������������������n���������������������`�n�����Ȕ����������������n�����Д���������������n���������������������n�����������������������n����������������������C�����������������������C������0����������������C������`�����������������n�����h�����������������n�����������������������n��������������������� �n�����������������������n���������������������`�n����������������������C������ؕ���������������C��������������������0�n���������������������@�n���������������������p�n����������������������C������H���������������`�o�����h����������������Eo���������������������p[P����������������������5������������������������������Ȗ���������������n�����������������������Ro����������������������J����������������������q�������0���������������q�������H���������������q�������`�����������������������x�����������������������������������������������������������������������������������������������ؗ���������������~���������������������~�����������������������~������ ����������������~������8����������������~������P����������������~������h����������������~�����������������������~�����������������������qo����������������������uo�����И����������������n�����ؘ���������������uo���������������������o���������������������0�o���������������������`�o���������������������p�o�����������������������o�����������������������o����� �����������������o�����(�����������������o�����0�����������������o�����8���������������`�o�����@���������������p�o�����H�����������������o�����P�����������������o�����X�����������������o�����`�����������������o�����h�����������������������p���������������p$|�����x�����������������n���������������������������������������������p
+|���������������������P�n���������������������p
... diff truncated: showing 553 of 360280 lines
This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

ericapisani and others added 4 commits March 6, 2026 14:40
…when None

The execute_tool_span function now skips setting GEN_AI_TOOL_DESCRIPTION when
tool_definition.description is None, instead of setting it to None. Update the
corresponding test to verify the key is absent from span data rather than
present with a None value, and rename the test to reflect this behavior.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
ericapisani and others added 6 commits March 9, 2026 09:06
The OpenAI API always returns the response model for both Completions and Responses APIs. The test previously mocked a Responses object without a response model, which cannot occur when using the Responses API with `openai-agents`.
### Description
Add `sentry_sdk.traces.start_span` and the corresponding scope method.

NOTE: This is experimental and not production ready code.

#### Issues
<!--
* resolves: #1234
* resolves: LIN-1234
-->

#### Reminders
- Please add tests to validate your changes, and lint your code using
`tox -e linters`.
- Add GH Issue ID _&_ Linear ID (if applicable)
- PR title should use [conventional
commit](https://develop.sentry.dev/engineering-practices/commit-messages/#type)
style (`feat:`, `fix:`, `ref:`, `meta:`)
- For external contributors:
[CONTRIBUTING.md](https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md),
[Sentry SDK development docs](https://develop.sentry.dev/sdk/), [Discord
community](https://discord.gg/Ww9hbqr)
### Description
Add the new `sentry_sdk.traces.continue_trace` and
`sentry_sdk.traces.new_trace` APIs.

#### Issues
<!--
* resolves: #1234
* resolves: LIN-1234
-->

#### Reminders
- Please add tests to validate your changes, and lint your code using
`tox -e linters`.
- Add GH Issue ID _&_ Linear ID (if applicable)
- PR title should use [conventional
commit](https://develop.sentry.dev/engineering-practices/commit-messages/#type)
style (`feat:`, `fix:`, `ref:`, `meta:`)
- For external contributors:
[CONTRIBUTING.md](https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md),
[Sentry SDK development docs](https://develop.sentry.dev/sdk/), [Discord
community](https://discord.gg/Ww9hbqr)
…esponse tests (#5600)

Replace mocks with `httpx` types to avoid test failures when library internals change.
### Description
Add the streaming equivalent of the `@trace` decorator.

#### Issues
<!--
* resolves: #1234
* resolves: LIN-1234
-->

#### Reminders
- Please add tests to validate your changes, and lint your code using
`tox -e linters`.
- Add GH Issue ID _&_ Linear ID (if applicable)
- PR title should use [conventional
commit](https://develop.sentry.dev/engineering-practices/commit-messages/#type)
style (`feat:`, `fix:`, `ref:`, `meta:`)
- For external contributors:
[CONTRIBUTING.md](https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md),
[Sentry SDK development docs](https://develop.sentry.dev/sdk/), [Discord
community](https://discord.gg/Ww9hbqr)
sentrivana and others added 6 commits March 9, 2026 09:12
`potel-base` has been abandoned, don't run actions on it
)

Replace mocks with `httpx` types to avoid test failures when library internals change.
Replace mocks with `httpx` types to avoid test failures when library internals change.
)

Replace mocks with `httpx` types to avoid test failures when library internals change.
….com:getsentry/sentry-python into ep/add-tool-description-to-pydantic-ai-spans
Copy link
Contributor

@alexander-alderman-webb alexander-alderman-webb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

span.set_data(
SPANDATA.GEN_AI_TOOL_DESCRIPTION,
tool_definition.description,
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty description still set in span data

Medium Severity

The condition if tool_definition is not None and hasattr(tool_definition, "description") doesn't filter out empty descriptions. Pydantic-ai's ToolDefinition is a dataclass where description: str is a required field — for tools without docstrings, it's set to "". Since the attribute always exists, hasattr returns True and span.set_data is called with an empty string. This contradicts the intended behavior (and the corresponding test assertion) that the GEN_AI_TOOL_DESCRIPTION key be omitted when no meaningful description exists. The condition also needs to check that tool_definition.description is truthy.

Fix in Cursor Fix in Web

….com:getsentry/sentry-python into ep/add-tool-description-to-pydantic-ai-spans
@ericapisani ericapisani enabled auto-merge (squash) March 9, 2026 14:19
@ericapisani ericapisani merged commit e0dd66c into master Mar 9, 2026
151 of 157 checks passed
@ericapisani ericapisani deleted the ep/add-tool-description-to-pydantic-ai-spans branch March 9, 2026 15:15
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.

3 participants

X Tutup