-
Notifications
You must be signed in to change notification settings - Fork 116
feat: add parallel tool orchestration with bounded concurrency #167
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
base: main
Are you sure you want to change the base?
Changes from all commits
59fc089
f91ad08
3c8819a
f832351
567d784
bd3f750
fe8eb1e
f7b0748
06191bd
28d256e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,8 @@ | |
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import {isPlainObject} from 'lodash-es'; | ||
|
|
||
| import {ToolConfirmation} from '../tools/tool_confirmation.js'; | ||
|
|
||
| // TODO: b/425992518 - Replace 'any' with a proper AuthConfig. | ||
|
|
@@ -59,6 +61,11 @@ export interface EventActions { | |
| * call id. | ||
| */ | ||
| requestedToolConfirmations: {[key: string]: ToolConfirmation}; | ||
|
|
||
| /** | ||
| * Optional metadata for framework-level runtime coordination. | ||
| */ | ||
| customMetadata?: {[key: string]: unknown}; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -72,6 +79,7 @@ export function createEventActions( | |
| artifactDelta: {}, | ||
| requestedAuthConfigs: {}, | ||
| requestedToolConfirmations: {}, | ||
| customMetadata: {}, | ||
| ...state, | ||
| }; | ||
| } | ||
|
|
@@ -85,6 +93,25 @@ export function createEventActions( | |
| * 2. For other properties (skipSummarization,transferToAgent, escalate), the | ||
| * last one wins. | ||
| */ | ||
| function deepMergeStateDelta( | ||
| target: Record<string, unknown>, | ||
| source: Record<string, unknown>, | ||
| ): void { | ||
| for (const [key, srcValue] of Object.entries(source)) { | ||
| const targetValue = target[key]; | ||
|
|
||
| if (isPlainObject(targetValue) && isPlainObject(srcValue)) { | ||
| const nestedTarget = {...(targetValue as Record<string, unknown>)}; | ||
| deepMergeStateDelta(nestedTarget, srcValue as Record<string, unknown>); | ||
| target[key] = nestedTarget; | ||
| continue; | ||
| } | ||
|
|
||
| // Preserve explicit undefined writes as last-write-wins for clear semantics. | ||
| target[key] = srcValue; | ||
| } | ||
| } | ||
|
|
||
|
Comment on lines
+96
to
+114
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure that we need this, see https://github.com/google/adk-js/pull/167/changes#r2875471658 |
||
| export function mergeEventActions( | ||
| sources: Array<Partial<EventActions>>, | ||
| target?: EventActions, | ||
|
|
@@ -99,7 +126,7 @@ export function mergeEventActions( | |
| if (!source) continue; | ||
|
|
||
| if (source.stateDelta) { | ||
| Object.assign(result.stateDelta, source.stateDelta); | ||
| deepMergeStateDelta(result.stateDelta, source.stateDelta); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we use |
||
| } | ||
| if (source.artifactDelta) { | ||
| Object.assign(result.artifactDelta, source.artifactDelta); | ||
|
|
@@ -113,6 +140,12 @@ export function mergeEventActions( | |
| source.requestedToolConfirmations, | ||
| ); | ||
| } | ||
| if (source.customMetadata) { | ||
| result.customMetadata = Object.assign( | ||
| result.customMetadata ?? {}, | ||
| source.customMetadata, | ||
| ); | ||
| } | ||
|
Comment on lines
+143
to
+148
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure that we need this at all. |
||
|
|
||
| if (source.skipSummarization !== undefined) { | ||
| result.skipSummarization = source.skipSummarization; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this field in
eventActions?