Skip to content

Commit 5f7d0d6

Browse files
authored
Add run context to handoff input filter to align with Python SDK (#271)
1 parent 7b437d9 commit 5f7d0d6

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

.changeset/shiny-months-smoke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@openai/agents-core": patch
3+
---
4+
5+
Add run context to handoff input filter to align with Python SDK

packages/agents-core/src/extensions/handoffFilters.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ const TOOL_TYPES = new Set([
2424
export function removeAllTools(
2525
handoffInputData: HandoffInputData,
2626
): HandoffInputData {
27-
const { inputHistory, preHandoffItems, newItems } = handoffInputData;
27+
const { inputHistory, preHandoffItems, newItems, runContext } =
28+
handoffInputData;
2829

2930
const filteredHistory = Array.isArray(inputHistory)
3031
? removeToolTypesFromInput(inputHistory)
@@ -37,6 +38,7 @@ export function removeAllTools(
3738
inputHistory: filteredHistory,
3839
preHandoffItems: filteredPreHandoffItems,
3940
newItems: filteredNewItems,
41+
runContext,
4042
};
4143
}
4244

packages/agents-core/src/handoff.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ export type HandoffInputData = {
3434
* handoff and the tool output message representing the response from the handoff output.
3535
*/
3636
newItems: RunItem[];
37+
/**
38+
* The context of the handoff.
39+
* Note that, since this property was added later on, it's optional to pass from users.
40+
*/
41+
runContext?: RunContext<any>;
3742
};
3843

3944
export type HandoffInputFilter = (input: HandoffInputData) => HandoffInputData;

packages/agents-core/src/runImplementation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,7 @@ export async function executeHandoffCalls<
10251025
: originalInput,
10261026
preHandoffItems: [...preStepItems],
10271027
newItems: [...newStepItems],
1028+
runContext,
10281029
};
10291030

10301031
const filtered = inputFilter(handoffInputData);

0 commit comments

Comments
 (0)