Get started
You can use the harness through the AgentCore CLIboto3. The CLI is the fastest path for most developers; SDKs are for programmatic use from your own application.
Prerequisites
-
AWS credentials configured in one of the supported regions.
-
For the CLI: Install and configure the AgentCore CLI as described in Get started with the AgentCore CLI.
-
For the SDK/boto3: Python 3.10+,
boto3installed, and an IAM execution role the harness can assume. See the execution role policy for minimum permissions.
Get started
Example
That’s all you need to get a harness running. The following sections cover everything you can configure.
Note
The runtimeSessionId must be at least 33 characters. Use a UUID or similar identifier. Reuse the same session ID across invocations to continue a conversation in the same environment.
Supply an end-user ID
Use --user-id when your application needs to send an end-user identifier with a Harness invocation. It is separate from --session-id and the Memory configuration’s actorId. If you omit it, the CLI sends no Harness user ID. The value does not replace inbound authentication.
For a project Harness:
agentcore invoke --harness MyResearchAgent \ --user-id user-123 \ --session-id "$(uuidgen)" \ --prompt "Summarize my research."
For a deployed Harness by ID, no project is required. The same option works in interactive chat when you omit --prompt:
agentcore harness invoke --id <harness-id> \ --user-id user-123 \ --session-id "$(uuidgen)"
Test a Harness with the Agent Inspector
For a Harness project, agentcore dev --mode browser deploys the project and opens a local Agent Inspector that invokes the deployed Harness in AWS. It does not run the Harness locally. Deployment can create or update project resources, and cloud invocations can incur charges.
Run this command from the project root:
agentcore dev --mode browser
To use the deployed configuration without deploying again:
agentcore dev --mode browser --skip-deploy
Use --target to select an entry in agentcore/aws-targets.json, and --ui-port to choose the local Inspector port. In a project containing both Runtimes and Harnesses, use --agent to select one:
agentcore dev --agent MyResearchAgent \ --mode browser \ --target default \ --ui-port 8082
Harness requests use the selected deployment target’s Region and credentials. Without --mode browser, the default headless mode deploys unless you pass --skip-deploy, prints invocation guidance, and exits. It does not start a local server or chat session.
Runtime-only --port and --no-traces options do not apply to Harness development. This path does not start a local Runtime or OpenTelemetry collector. Use Harness operations for cloud observability, or open a Harness shell to inspect its execution environment.
API Documentation
For additional details, see the API Reference:
Streaming response format
InvokeHarness returns a stream of events. The key event types are:
-
messageStart- beginning of a new message (includesrole) -
contentBlockStart- beginning of a content block (text,toolUse, ortoolResult) -
contentBlockDelta- incremental content (text,toolUseinput,toolResultcontent,reasoningContent) -
contentBlockStop- end of a content block -
messageStop- end of the message (includesstopReason) -
metadata- token usage and latency metrics -
hookEvent- a configured lifecycle hook fired. Lambda hook events include the applied decision and optional reason. See Lifecycle hooks. -
runtimeClientError- error during execution
The stopReason in messageStop indicates why the current streamed message ended:
-
end_turn- the agent finished normally -
tool_use- the model requested one or more tools. The harness can continue with harness-executed tools. If this is the finalmessageStopin the completed response stream, the harness is waiting for an inline function result. -
tool_result- the harness streamed one or more tool results; additional model output can follow -
max_tokens- the model’s per-turn token limit was reached -
max_iterations_exceeded- themaxIterationslimit was hit -
timeout_exceeded- thetimeoutSecondslimit was hit -
max_output_tokens_exceeded- themaxTokensbudget was exhausted -
hook_stopped- adenydecision from abefore_invocationorafter_tool_callLambda hook stopped the invocation