Commit c6fd6fe
authored
fix(agent): pass toolCallId in context.agent for network tool execution (#10951)
**Critical Issue**: When tools are executed through the agent network,
the `context.agent.toolCallId` property is **undefined** despite being
required by the TypeScript type definitions. This creates a type safety
gap where the runtime behavior does not match the type contract.
### Type Definition vs Implementation Mismatch
The `AgentToolExecutionContext` type (from
`packages/core/src/tools/types.ts`) defines toolCallId as a required
string property:
```typescript
export interface AgentToolExecutionContext {
toolCallId: string; // ← Required, non-optional
messages: any[];
threadId?: string;
resourceId?: string;
}
```
However, when tools execute through the network loop, `toolCallId` was
never passed to the context, violating the type contract and leaving
tools without access to a critical identifier.
### The Fix
This PR brings the runtime implementation into alignment with TypeScript
type definitions by passing the `toolCallId` generated during network
tool execution through to `context.agent`. Tools can now reliably
access:
- `context.agent.toolCallId` - Unique identifier for this tool call
- `context.agent.threadId` - Memory thread identifier
- `context.agent.resourceId` - Memory resource identifier
All three properties now properly propagate through network execution,
matching their type definitions.
## Related Issue(s)
Brings runtime implementation into alignment with type definitions for
AgentToolExecutionContext
## Type of Change
- [x] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [ ] Code refactoring
- [ ] Performance improvement
- [ ] Test update
## Checklist
- [x] I have made corresponding changes to the documentation (if
applicable)
- [x] I have added tests that prove my fix is effective or that my
feature works
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Tests**
* Added validation tests to confirm tools receive a complete agent
context (including call identifiers) during network execution.
* **Improvements**
* Tools now receive the call identifier (toolCallId) in their execution
context for improved tracking and visibility at runtime.
* **Chores**
* Recorded a patch changeset documenting the fix.
<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent 0364624 commit c6fd6fe
File tree
3 files changed
+91
-1
lines changed- .changeset
- packages/core/src
- agent
- loop/network
3 files changed
+91
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
697 | 698 | | |
698 | 699 | | |
699 | 700 | | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
957 | 957 | | |
958 | 958 | | |
959 | 959 | | |
| 960 | + | |
960 | 961 | | |
961 | 962 | | |
962 | 963 | | |
| |||
0 commit comments