-
Notifications
You must be signed in to change notification settings - Fork 53.5k
Tool Call Reasoning Example #19232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
igordayen
wants to merge
4
commits into
eugenp:master
Choose a base branch
from
igordayen:tools-selection-reasoning
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+608
−0
Open
Tool Call Reasoning Example #19232
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| ## ENVIRONMENT SETUP | ||
| ``` | ||
| OPENAI_API_KEY=<your-key> | ||
| ``` | ||
|
|
||
| ## TEST EXECUTION | ||
|
|
||
| ```bash | ||
| mvn test -Dtest=ToolCallReasoningIntegrationTest | ||
|
|
||
| ``` | ||
|
|
||
| ## SAMPLE OUTPUT | ||
|
|
||
| ```bash | ||
| 15:07:21.793 [main] INFO ToolCallReasoningIntegrationTest - | ||
| ========== RESULT (11979 ms) ========== | ||
| Recommended: ParkingRecommendation[chosenOption=GARAGE, location=Midtown Manhattan, estimatedTotalCost=90, summary=No feasible street or metered parking was found within the required time and duration constraints. Garage parking was reserved to guarantee on-time arrival and accommodate the 3-hour meeting despite higher cost.] | ||
| Reasoning: [ThinkingBlock(content=Tool: [tool=functions.findStreetParking] | ||
| Why THIS tool: To explore the availability and location of free street parking near the client meeting area. | ||
| Information expected: The real-time availability or likelihood of securing street parking within required proximity and time. | ||
| Advantage over alternatives: Street parking is the lowest cost option but uncertain; assessing its availability directly helps gauge risk of delay. | ||
| Confidence in this tool selection [confidence=0.85], tagType=TAG, tagValue=tool_use_reasoning), ThinkingBlock(content=Tool: [tool=functions.findMeterParking] | ||
| Why THIS tool: To check for metered parking availability for suitable duration nearby, as it offers moderate cost and may partially fit time needs. | ||
| Information expected: Metered parking availability, pricing, and time limits relevant to the 3-hour meeting. | ||
| Advantage over alternatives: It balances cost and reliability better than street parking, useful for moderate risk tolerance. | ||
| Confidence in this tool selection [confidence=0.9], tagType=TAG, tagValue=tool_use_reasoning), ThinkingBlock(content=Tool: [tool=functions.reserveGarage] | ||
| Why THIS tool: Since street and metered parking are unavailable or impractical given the time constraint and duration, reserving guaranteed garage parking is a reliable fallback. | ||
| Information expected: Confirmation of garage parking availability and reservation to ensure on-time arrival with minimal risk. | ||
| Advantage over alternatives: Eliminates uncertainty and risk of being late by guaranteeing parking close to the meeting. | ||
| Confidence in this tool selection [confidence=0.95], tagType=TAG, tagValue=tool_use_reasoning), ThinkingBlock(content=The probe for street parking revealed no available spots within a feasible 30-minute timeframe, making it too risky given the tight schedule and meeting start time. Metered parking was also found unavailable very quickly nearby, plus it imposes a 2-hour limit which is insufficient for the 3-hour meeting. These results demonstrate that free and moderate-cost options are either not accessible or impractical due to time and duration constraints. Given these factors, reserving the garage parking emerged as the best alternative, offering guaranteed availability and eliminating the risk of lateness. Although it is the most expensive option ($30 per hour), it aligns best with the client's priority of punctuality and the meeting's long duration. Confidence in this recommendation is high [confidence=0.95]., tagType=TAG, tagValue=final_decision_reasoning)] | ||
|
|
||
| Callback stats: | ||
| beforeLlmCall: 3 | ||
| afterLlmCall: 3 | ||
| afterToolResult: 3 | ||
|
|
||
|
|
||
| 15:07:21.797 [main] INFO ToolCallReasoningIntegrationTest - Tools invoked: [findStreetParking, findMeterParking, reserveGarage] | ||
| 15:07:21.797 [main] INFO ToolCallReasoningIntegrationTest - === TOOL CALL PATTERN ANALYSIS === | ||
| 15:07:21.797 [main] INFO ToolCallReasoningIntegrationTest - Total LLM iterations: 3 | ||
| 15:07:21.797 [main] INFO ToolCallReasoningIntegrationTest - Total tools called: 3 | ||
| 15:07:21.797 [main] INFO ToolCallReasoningIntegrationTest - Tool result callbacks: 3 | ||
| 15:07:21.797 [main] INFO ToolCallReasoningIntegrationTest - PATTERN: Multiple tools called in SAME iteration (parallel tool calls) | ||
| 15:07:21.797 [main] INFO ToolCallReasoningIntegrationTest - Thinking blocks captured: 4 | ||
| 15:07:21.797 [main] INFO ToolCallReasoningIntegrationTest - Block 1: tagType=TAG, tagValue=tool_use_reasoning, contentLength=475 | ||
| 15:07:21.798 [main] INFO ToolCallReasoningIntegrationTest - Attributes: {confidence=0.85, tool=functions.findStreetParking} | ||
| 15:07:21.798 [main] INFO ToolCallReasoningIntegrationTest - Tool: functions.findStreetParking | ||
| 15:07:21.798 [main] INFO ToolCallReasoningIntegrationTest - Confidence: 0.85 | ||
| 15:07:21.798 [main] INFO ToolCallReasoningIntegrationTest - Block 2: tagType=TAG, tagValue=tool_use_reasoning, contentLength=473 | ||
| 15:07:21.798 [main] INFO ToolCallReasoningIntegrationTest - Attributes: {confidence=0.9, tool=functions.findMeterParking} | ||
| 15:07:21.798 [main] INFO ToolCallReasoningIntegrationTest - Tool: functions.findMeterParking | ||
| 15:07:21.798 [main] INFO ToolCallReasoningIntegrationTest - Confidence: 0.9 | ||
| 15:07:21.798 [main] INFO ToolCallReasoningIntegrationTest - Block 3: tagType=TAG, tagValue=tool_use_reasoning, contentLength=515 | ||
| 15:07:21.798 [main] INFO ToolCallReasoningIntegrationTest - Attributes: {confidence=0.95, tool=functions.reserveGarage} | ||
| 15:07:21.798 [main] INFO ToolCallReasoningIntegrationTest - Tool: functions.reserveGarage | ||
| 15:07:21.798 [main] INFO ToolCallReasoningIntegrationTest - Confidence: 0.95 | ||
| 15:07:21.798 [main] INFO ToolCallReasoningIntegrationTest - Block 4: tagType=TAG, tagValue=final_decision_reasoning, contentLength=808 | ||
| 15:07:21.798 [main] INFO ToolCallReasoningIntegrationTest - Attributes: {confidence=0.95} | ||
| 15:07:21.798 [main] INFO ToolCallReasoningIntegrationTest - Confidence: 0.95 | ||
| [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 16.30 s -- in com.baeldung.embabel.agent.api.tool.loop.thinking.ToolCallReasoningIntegrationTest | ||
| [INFO] | ||
| [INFO] Results: | ||
| [INFO] | ||
| [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 | ||
|
|
||
|
|
||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <parent> | ||
| <groupId>com.baeldung</groupId> | ||
| <artifactId>embabel-modules</artifactId> | ||
| <version>0.0.1</version> | ||
| </parent> | ||
|
|
||
| <artifactId>embabel-tool-reasoning</artifactId> | ||
|
|
||
| <properties> | ||
| <maven.compiler.source>21</maven.compiler.source> | ||
| <maven.compiler.target>21</maven.compiler.target> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| <embabel-agent.version>0.4.0</embabel-agent.version> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
|
|
||
| <!-- Embabel Agent API --> | ||
| <dependency> | ||
| <groupId>com.embabel.agent</groupId> | ||
| <artifactId>embabel-agent-api</artifactId> | ||
| <version>${embabel-agent.version}</version> | ||
| </dependency> <!-- Embabel Agent Starter --> | ||
| <dependency> | ||
| <groupId>com.embabel.agent</groupId> | ||
| <artifactId>embabel-agent-starter-shell</artifactId> | ||
| <version>${embabel-agent.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.embabel.agent</groupId> | ||
| <artifactId>embabel-agent-starter-openai</artifactId> | ||
| <version>${embabel-agent.version}</version> | ||
| </dependency> | ||
|
|
||
| <!-- Embabel Agent Test Support --> | ||
| <dependency> | ||
| <groupId>com.embabel.agent</groupId> | ||
| <artifactId>embabel-agent-test-internal</artifactId> | ||
| <version>${embabel-agent.version}</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <configuration> | ||
| <source>${maven.compiler.source}</source> | ||
| <target>${maven.compiler.source}</target> | ||
| <release>${maven.compiler.source}</release> | ||
| </configuration> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-maven-plugin</artifactId> | ||
| <executions> | ||
| <execution> | ||
| <id>repackage</id> | ||
| <configuration> | ||
| <skip>true</skip> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
|
|
||
| </project> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.