Skip to content

Draft: workflows#497

Draft
kalenkevich wants to merge 13 commits into
mainfrom
feature/workflows
Draft

Draft: workflows#497
kalenkevich wants to merge 13 commits into
mainfrom
feature/workflows

Conversation

@kalenkevich

Copy link
Copy Markdown
Collaborator

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

  • Closes: #issue_number
  • Related: #issue_number

2. Or, if no issue exists, describe the change:

If applicable, please follow the issue templates to provide as much detail as
possible.

Problem:
A clear and concise description of what the problem is.

Solution:
A clear and concise description of what you want to happen and why you choose
this solution.

Testing Plan

Please describe the tests that you ran to verify your changes. This is required
for all PRs that are not small documentation or typo fixes.

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Please include a summary of passed npm test results.

Manual End-to-End (E2E) Tests:

Please provide instructions on how to manually test your changes, including any
necessary setup or configuration. Please provide logs or screenshots to help
reviewers better understand the fix.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

Add any other context or screenshots about the feature request here.

Port the leaf data types for the new BaseNode/Context workflow architecture (parity with google/adk-python): NodeStatus (Python-aligned ordinals), Python-shaped NodeState, RetryConfig with jitter/exceptions + retry utils, and workflow errors. Extend the shared Event/EventActions model additively with first-class workflow fields (output, route, nodeInfo, isolationScope, agentState, endOfAgent) that round-trip through snake_case for cross-language session compatibility.
Add the load-bearing core: an EventChannel primitive bridging the engine's push model to the runtime's pull model; the workflow NodeContext (ctx.runNode, delta-aware ctx.state, output/route/interruptIds/isolationScope/nodePath); the new BaseNode with a run() normalizer (Event | raw | null -> Event) and START sentinel; and a per-node NodeRunner handling event enrichment, output delegation, sub-branches, retry (Python check-then-increment) and per-node timeout.
Add the static-graph engine: Graph/Edge/RoutingMap/NodeLike with route values (bool|number|string), a graph parser (chains, fan-out, routing maps) and validator (reachability, duplicate/START rules, unconditional-cycle detection), Trigger as a data record, and Workflow(BaseNode) whose orchestration loop seeds START, schedules ready nodes, races completions, buffers downstream triggers, fans in via requiresAllPredecessors, and finalizes terminal output. Fixes the initial-input-propagation bug.
Add the node() factory and subclassable Node, plus concrete node types: FunctionNode (idiomatic (ctx,input) handler with value/promise/generator support, Content coercion, state-delta capture, zod schema validation), JoinNode (fan-in barrier), and ToolNode (wraps a BaseTool, bridges to the tool Context, coerces args). buildNode now wraps functions and tools.
Add ScheduleDynamicNode + DynamicNodeScheduler (fresh execution, concurrent-call dedup by run path) and wire ctx.runNode() through it with per-name run-id generation. Workflow gains a dynamicEntry mode for imperative orchestration (loops, conditionals, node-as-tool), fixing the cycle-hang for the imperative path. The static loop bypasses the scheduler.
Add RequestInput and HITL utils (adk_request_input interrupt events, longRunningToolIds). BaseNode.run() normalizes a yielded/returned RequestInput into an interrupt event; the NodeRunner collects interrupt ids and the Workflow/scheduler propagate them so the workflow pauses and surfaces interrupt ids. Resume inputs flow back via ctx.resumeInputs. (Session rehydration, replay determinism, checkpoints and the auth gate remain as Phase 5b, pending Runner integration.)
Add BranchPath (hierarchical name@runId paths: createSubBranch, commonPrefix, isDescendantOf) and ParallelWorker (maps a list input across the inner node with bounded concurrency, order preservation, cancel-on-first-error). node()/buildNode support {parallelWorker, maxParallelWorkers}; sub-branch derivation and fan-in common-prefix now use BranchPath.
Add LLMAgentWrapper (single_turn): append the node input as a user turn, run the agent under the node's invocation context, and promote its final model text to the node output. buildNode now wraps BaseAgent (and agent-like objects), so node(agent) works and agents can be used directly in edges. (task/chat modes with FinishTaskTool, delegation, transfer and isolation scopes remain as Phase 7b.)
Add WorkflowAgent, a BaseAgent adapter that runs a Workflow (a BaseNode) via the standard ADK Runner: it sets up the event-channel bridge and maps the user message to the workflow input. Add the module barrel (index.ts) exposing the public surface (Workflow, WorkflowAgent, BaseNode, Node, node, FunctionNode, JoinNode, ToolNode, ParallelWorker, LLMAgentWrapper, Edge, START, DEFAULT_ROUTE, RequestInput, RetryConfig, NodeTimeoutError, ...). Includes an end-to-end integration test proving sequence, routing and DEFAULT_ROUTE workflows run through the real Runner + InMemorySessionService.
…gine

Replace the old BaseAgent/InvocationContext-based workflow module with the new Python-parity BaseNode/Context implementation: delete core/src/workflow, rename workflow-next -> workflow (the @google/adk barrel already points at ./workflow/index.js), and move the test suite to core/test/workflow. Remove the old-module unit, sample, and integration tests (superseded by the 82 workflow tests, including end-to-end Runner integration). BREAKING CHANGE: the @google/adk workflow API is now the new node-based model (Workflow is a BaseNode; run it via WorkflowAgent).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants