AI Agent - Aug 8, 2026

n8n AgentCore Model Switching Guide: Bedrock to OpenAI

Quick answer

Amazon Bedrock AgentCore Harness can select a model per invocation, so an n8n workflow can keep the same actor and session IDs while changing from one supported model configuration to another. Harness documents Amazon Bedrock, OpenAI, Gemini, and LiteLLM configurations.

The memory continuity is convenient, but it does not make models interchangeable. Validate tool calls, instruction adherence, context use, latency, token accounting, safety controls, and cost before enabling a route.

Separate conversation state from model choice

Three inputs serve different purposes:

  • actorId identifies the user or tenant memory boundary;
  • runtimeSessionId identifies the conversation;
  • model selects the provider, model ID, credentials, API format, and parameters for this invocation.

To compare two models in one conversation, keep actor and session stable and change only the model configuration. To run a clean A/B evaluation without prior conversational influence, create separate sessions and replay the same fixtures.

Provider decision table

Provider pathCredential patternImportant check
Amazon BedrockHarness execution roleRegion, model access, inference profile, API format
OpenAI directAgentCore Identity API key ARNResponses vs. Chat Completions, key scope, endpoint
OpenAI via Bedrock MantleExecution roleSupported endpoint, model, and API format
GeminiAgentCore Identity API key ARNModel ID, key scope, provider behavior
LiteLLMExecution role for Bedrock prefix or API key ARN for other providersProvider-prefixed model ID, custom endpoint, parameter validation

AWS documents that Bedrock and OpenAI configurations can choose API formats. Bedrock’s default is Converse Stream; supported OpenAI-compatible formats use the relevant Bedrock endpoint. The format and endpoint can change available models and capabilities, so treat them as part of the route, not an incidental setting.

Build a routing policy in n8n

Do not let arbitrary workflow input become a raw model configuration. Map a small, reviewed route name to a server-side configuration:

fast-summary -> approved low-latency model + strict token cap
tool-task    -> approved tool-tested model + allowlisted tools
deep-review  -> approved reasoning model + higher bounded timeout
fallback     -> approved alternate provider + reduced capabilities

Validate any fields that can alter endpoints, region selection, credential handling, or provider parameters. AWS explicitly warns that additional parameters can change routing and credential behavior.

Preserve credentials and least privilege

Bedrock calls generally rely on the harness execution role. Direct OpenAI, Gemini, and many LiteLLM providers use API keys stored through AgentCore Identity. The execution role needs permission to retrieve only the intended credential provider and its backing secret.

The n8n workflow should pass an approved model route or configuration reference, not the secret. Keep deploy rights, secret-management rights, and invoke rights separate.

Evaluate before switching production traffic

Create a fixed test set that covers:

  1. direct answers with known facts;
  2. correct and incorrect tool selection;
  3. denied or unavailable tool behavior;
  4. multi-turn memory and early-session constraints;
  5. long context and truncation;
  6. structured output parsing in later n8n nodes;
  7. provider timeout, throttling, and fallback;
  8. safety and data-handling requirements.

Measure task success, tool accuracy, schema validity, latency, input/output tokens, retries, and total downstream cost. A lower model price may still cost more if it loops, retries, or triggers unnecessary tools.

Safe mid-session switch checklist

  • Keep actor/session identifiers stable only when continuity is desired.
  • Record the selected model and route in workflow and Harness telemetry.
  • Reconfirm tool compatibility and system instructions for the destination model.
  • Cap iterations, time, and tokens on every route.
  • Avoid automatic fallback for side-effecting steps unless idempotency is proven.
  • Explain model changes to users when they materially affect behavior or data processing.
  • Re-run evaluations after model, provider, API-format, or prompt changes.

Frequently asked questions

Can AgentCore Harness switch models during one session?

Yes. AWS documents per-invocation model overrides and mid-session switching. Keep the same actor and runtime session IDs when the conversation should continue.

Which model providers does Harness support?

AWS documents configurations for Amazon Bedrock, OpenAI, Gemini, and providers reached through LiteLLM. Support, models, Regions, and API formats can change, so check current documentation.

Where should non-Bedrock API keys be stored?

Store them in AgentCore Identity API key credential providers and grant the harness execution role only the required read permissions. Do not place raw keys in n8n prompts or workflow JSON.

Does switching models guarantee identical answers?

No. Models differ in tool calling, context handling, safety behavior, latency, price, and output. Run a fixed evaluation set before routing production traffic.

Continue by decision

Official sources

Source check: August 8, 2026. Verify current provider support, API formats, model IDs, Regions, credentials, quotas, safety features, and prices before use.