Menu
AWS Architecture Blog·October 21, 2026

Orchestrating AI Agents for Deterministic Workflows with Step Functions and Bedrock

This article demonstrates an architectural pattern for integrating AI agents into critical workflows using AWS Step Functions and Amazon Bedrock. It highlights the importance of deterministic orchestration for auditing and replayability, ensuring that AI agents handle bounded tasks while the workflow engine manages sequencing and approvals. The medical coding example illustrates how to combine cheaper, deterministic mechanisms with AI agents for enhanced efficiency and control in sensitive domains.

Read original on AWS Architecture Blog

The Challenge of AI in Deterministic Workflows

Integrating AI agents into workflows, especially in regulated industries like healthcare, presents a challenge: how to leverage the reasoning power of AI while maintaining determinism, audibility, and human oversight. Handing an entire workflow to an AI agent makes the execution path a property of the model's reasoning, which is difficult to review and replay. This architecture addresses this by dividing labor: the workflow engine (Step Functions) owns sequencing and approval gates, while AI agents (Amazon Bedrock AgentCore) reason within individual, bounded steps.

Hybrid Approach: Deterministic Logic First, AI for Judgment

The core design principle is to apply the cheapest, most deterministic mechanism first, escalating to more complex solutions only when necessary. For medical coding, this means a multi-stage approach:

  1. Safety Block-list: Immediately identify and flag terms that should *never* be autocoded, regardless of AI reasoning. This is a hard control enforced before any model call.
  2. Exact Matching: Perform case-insensitive exact matches against a dictionary and curated synonym lists. This handles a significant portion of the workload efficiently and deterministically.
  3. AI Agent for Ambiguity: Only terms that cannot be resolved deterministically are passed to the AI agent. The agent's role is to apply judgment, such as deciding when to pull in additional context, rather than dictate the overall workflow.
ℹ️

Key Architectural Decision

The workflow, not the AI model, owns every routing and decision-making step. The AI agent might choose a medical code and its confidence, but it does not decide what happens next. This ensures that a compliance reviewer can understand the execution path independently of the agent's runtime reasoning.

Architecture Components and Flow

The solution leverages AWS Step Functions for orchestration, AWS Lambda for deterministic steps, and Amazon Bedrock AgentCore for the agentic step. Amazon Aurora PostgreSQL-Compatible Edition (Serverless v2) with pgvector serves as a unified data store for reference data and its embeddings, eliminating the need for a separate vector store.

  • Step Functions State Machine: Orchestrates the entire process, ensuring exactly-once execution and providing an audit trail. Each execution codes one verbatim.
  • AWS Lambda: Executes deterministic logic, such as the safety block-list and exact matching lookups.
  • Amazon Bedrock AgentCore Harness: Invokes the AI agent. The agent's contract (system prompt, tools) is defined in the workflow, not within a separate container, making it transparent and manageable.
  • Amazon Bedrock AgentCore Gateway: Exposes the agent's tools (e.g., `get_study_info`, `search_dictionary`) which query Aurora.
  • Amazon Aurora PostgreSQL with pgvector: Stores medical dictionaries and embeddings, enabling efficient semantic search.

Error paths in this system are designed to leave terms 'open' for human review or to fail explicitly for redrive, maintaining auditability and ensuring every record reaches a terminal status. The write-back step stores the full medical family tree of each symptom entry, alongside a one-sentence explanation from the agent, to provide comprehensive context for review and trace variance.

AWS Step FunctionsAmazon BedrockAI AgentsWorkflow OrchestrationDeterministic WorkflowsServerlessData GovernanceAuditability

Comments

Loading comments...