## Context
By default, the outputs of tools are sent to the LLM again. The LLM gets
to read the outputs, and produce a new response. There are cases where
this is not desired:
1. Every tool results in another round trip, and sometimes the output of
the tool is enough.
2. If you force tool use (via model settings `tool_choice=required`),
then the agent will just infinite loop.
This enables you to have different behavior, e.g. use the first tool
output as the final output, or write a custom function to process tool
results and potentially produce an output.
## Test plan
Added new tests and ran existing tests
Also added examples.
Closes#117
`assert len(spans) == 12` is a very weak assertion. This PR asserts the
exported traces and spans more precisely in a readable tree format. And
when the format of an exported trace/span changes (e.g. a new key is
added to every span), you can use `pytest --inline-snapshot=fix` to
update all relevant tests automatically. See
https://15r10nk.github.io/inline-snapshot/latest/ for more info.
## Changes
- In this handoff example, we need to use `first_agent` with
`random_number_tool`, instead of `second_agent` without that tool, since
the user is asking to generate a random number.
- fixed typo in comments
# Summary
This adds the missing TracingProcessor export to __init__.py.
# Behavior
When trying to add a custom tracing processor, the TracingProcessor
importing fails with not found error when trying the example usage
proposed in issue #164
Specifically this line throws the error:
`add_trace_processor(MyTracingProcessor("output"))`
# Expected Behavior
Inspecting the init file, simply the import/export was missing. Adding
these made the example code work for me
# Test plan
Local dev of example code in #164
# Issue number
#164
# Checks
None
These classes print a really long, unreadable output by default. This
trims it to the main useful info (i.e. output, last agent, overview of
run).
---
[//]: # (BEGIN SAPLING FOOTER)
* __->__ #196
* #195
This PR introduces a `strict_mode: bool = True` option to
`@function_tool`, allowing optional parameters when set to False. This
change enables more flexibility while maintaining strict JSON schema
validation by default.
resolves#43
## Changes:
- Added `strict_mode` parameter to `@function_tool` and passed it to
`function_schema` and `FunctionTool`.
- Updated `function_schema.py` to respect `strict_mode` and allow
optional parameters when set to False.
- Added unit tests to verify optional parameters work correctly,
including multiple optional params with different types.
## Tests:
- Verified function calls with missing optional parameters behave as
expected.
- Added async tests to validate behavior under different configurations.