Skip to content

Source Strands Harness SDK Docs

Reese Hodge edited this page Oct 9, 2026 · 6 revisions

Source: Strands Harness SDK docs

The current documentation for @strands-agents/sdk, the package Component-Agent-Runtime is built on. Read on 2026-09-29 against our pinned 1.19.0, and re-checked on 2026-10-01 against the same pages and the 1.19.0 type declarations. 1.19.0 (2026-09-22) was still the latest release then, so the 2026-10-01 corrections are errors in this record, not version drift. 1.20.0 followed on 2026-10-08. This page has not been re-read against it, and the pin is still 1.19.0. The pre-assembled product layered on top is Source-Strands-Harness-Docs.

This page records what the docs say now, emphasising where they contradict what Decision-Strands-SDK was written against at 1.4.0 and 1.15.0; several of its load-bearing claims have since expired.

The product split, and a three-way name collision

The docs now describe two separate products:

Name Package What it is
Strands Harness SDK @strands-agents/sdk Build-it-yourself primitives. This is what we use.
Strands harness @strands-agents/harness Pre-assembled agent with benchmarked defaults. Source-Strands-Harness-Docs

The GitHub repository is now strands-agents/harness-sdk.

Beware: "harness" now names three different things — the two above plus AgentCore Harness, an unrelated managed agent-loop service from AWS (see Source-AgentCore-Platform-2026). Recorded in Gotchas.

Hooks are interceptive, not observational

This is the correction that matters most.

Decision-Strands-SDK previously stated that hooks were "observational, not interceptive" and used that as a rationale for post-processing. The SDK docs contradict that claim, and the live invocation handler does not perform personality cleanup or stutter injection at all (#42):

  • BeforeToolCallEvent — the handler may substitute the tool by assigning event.selectedTool, and may rewrite event.toolUse.name.
  • AfterToolCallEvent — the handler may replace the result by assigning event.result.
  • BeforeToolCallEvent.cancel / BeforeToolsEvent.cancel — a handler may cancel a single tool or an entire batch before anything executes, producing error results instead. (Corrected 2026-10-01: this page said cancelTool, which is Python's cancel_tool. TypeScript names both cancel.)

The 1.19.0 declarations expose more interception points than the first read recorded:

Event Mutable property Effect
BeforeInvocationEvent cancel Refuse the whole invocation before any model call
BeforeModelCallEvent cancel Skip a model call
AfterModelCallEvent retry Re-issue the model call
AfterToolCallEvent retry Re-run the tool
AfterToolsEvent endTurn Stop the loop after a tool batch, optionally with content
AfterInvocationEvent resume Start a follow-up invocation

retry and resume are loops a hook can create without the model asking for one — each is a Concept-Budget-Ceiling risk if it lacks its own bound. Resuming after an interrupt takes interruptResponse objects, not plain strings.

Hooks also gained ordering and packaging:

  • HookOrder — SDK_FIRST (-100), DEFAULT (0), SDK_LAST (100).
  • agent.addHook() registers after construction.
  • Plugins bundle hooks, tools and state into one installable unit.

Whether hooks should be used for personality processing is a separate decision, not a foregone conclusion — see Decision-Strands-SDK and #42.

Native invocation limits

agent.invoke(prompt, { limits: { turns, outputTokens, totalTokens } }), with matching stop reasons limitTurns, limitOutputTokens, limitTotalTokens.

Corrected 2026-10-01 from maxTurns / maxTotalTokens / maxOutputTokens, names absent from the 1.19.0 declarations. outputTokens is cumulative across the loop, unlike BedrockModel's per-call maxTokens.

Two properties decide how much of our hand-rolled capping they can replace:

  • Limits are checked at the top of each loop iteration, not mid-call, so they bound the loop rather than a single model response.
  • Counters are per-invocation and reset on every call.

That second property is the constraint. Our Concept-Budget-Ceiling caps are per-session, across invocations, so these limits are a useful inner guard but not a replacement for the outer accounting.

Full stop-reason set in the 1.19.0 StopReason type: endTurn, stopSequence, toolUse, maxTokens, contentFiltered, guardrailIntervened, interrupt, cancelled, checkpoint, pauseTurn, refusal, modelContextWindowExceeded, plus the three limit reasons. The type is open (string & {}), so a handler switching on it needs a default arm. A cancelled invocation returns an AgentResult with stopReason: 'cancelled' rather than throwing.

One invocation per agent

A second invoke or stream on a running Agent throws ConcurrentInvocationError; there is no queueing mode or idempotency key. The docs call an Agent cheap to construct and the model provider the part worth reusing. Our handler builds a fresh Agent per request, as advised, but also a fresh BedrockModel (packages/agent/src/index.ts); the cost of that is unmeasured.

Cancellation

  • agent.cancel() — idempotent and thread-safe.
  • cancelSignal: AbortSignal — passed per invocation.
  • Tools receive context?.cancelSignal and are expected to forward it to fetch so in-flight work stops.

Documented TypeScript checkpoints: the top of each loop cycle, during model streaming, before tool execution, and between sequential tool executions. (Corrected 2026-10-01: the "during MCP tool execution" checkpoint recorded earlier is Python-only.)

Cancellation semantics differ by executor. In sequential mode a mid-flight cancel short-circuits tools that have not started; in concurrent mode everything has already launched, so each tool must observe cancelSignal itself.

Implementation (#43 / PR #46): the runtime passes a per-invocation cancelSignal, aborted on premature res.close, through agent.invoke to every tool's fetch; it does not call agent.cancel(). See Component-Agent-Runtime. No live streaming is implied (#45).

Three kinds of state

The docs separate state by lifetime, and the distinction is sharper than our current code treats it:

Kind TypeScript accessor Sent to the model? Lifetime
Conversation history agent.messages Yes Managed, auto-trimmed
Agent / app state agent.appState No Across requests
Invocation state result.invocationState No One invocation

Notes that matter for us:

  • The TypeScript accessor is appState, not state as in Python. The docs show both on the same page, which is an easy mis-transcription.
  • appState enforces JSON-serializability and throws otherwise.
  • Invocation state is shared by reference across every hook and tool in an invocation, so mutations propagate — a natural carrier for a request ID or a per-turn token budget.
  • Conversation history is trimmed by a conversation manager; the default SlidingWindowConversationManager keeps the most recent N message pairs and handles context-overflow by reducing context.
  • Tools called directly by application code are recorded in conversation history by default; pass { recordDirectToolCall: false } to keep them out of model context.

Session persistence

SessionManager composes a pluggable Storage backend — InMemoryStorage, LocalFileStorage, S3Storage, or a custom one — and persists conversation history plus agent state so an agent resumes across restarts.

  • saveLatestOn: 'message' | 'invocation' — default 'invocation'. The 'message' strategy writes far more often.
  • snapshotTrigger — a callback creating an immutable checkpoint on demand.
  • agent.sessionId — the manager's ID when one is attached, otherwise a random 8-character hex handle that is not persisted.
  • In TypeScript, initialization fails if no storage is provided (Python falls back to ./.strands/).
  • 1.19.0 also exports a snapshot-only FileStorage, passed as storage: { snapshot } in the harness docs' examples.
  • Single writer, no lock. Two live agents on one session id overwrite each other silently, and session creation is not atomic. The storage directory is trusted, and symlinks inside it are followed. Detailed on Source-Strands-Harness-Docs, whose checkpoints page documents these SDK managers.

This overlaps with AgentCore Memory, which we have declared but not built. The two are alternatives for the same job and the overlap is unresolved — see Decision-AgentCore-Runtime-V2. The docs now list an AgentCoreMemorySessionManager as a third-party session manager bridging the two, documented for Python only.

Bedrock provider

  • BedrockModel is the default provider in the TypeScript SDK; the default model is Claude Sonnet 4.6. We override both.
  • Prompt caching is supported on Bedrock via cacheConfig: { strategy: 'auto' }, or { messagesTTL: false } to cache only the system prompt and tool definitions. Of the listed providers only Bedrock, Anthropic, LiteLLM, llama.cpp and Vercel support it at all. This is an unproven Concept-Budget-Ceiling lever: no cache is configured, the system prompt alone is below Bedrock's 4,096-token checkpoint minimum, and the combined prompt/tool size has not been verified. See #49.
  • The full 1.19.0 CacheConfig is strategy ('auto' or 'anthropic'), ttl, and per-section toolsTTL, systemPromptTTL and messagesTTL, each true, false or a TTL. Bedrock rejects a longer TTL following a shorter one across tools, system and messages. strategy: 'auto' cannot inspect an application inference profile ARN and silently skips caching for it; set 'anthropic' explicitly. Our global.anthropic.* CRIS id is inspectable.
  • useNativeTokenCount: true asks Bedrock for exact token counts; if that is unsupported or unauthorized, the SDK caches the failure and silently falls back to a character heuristic. CountTokens is unsupported for our CRIS-only Haiku (Decision-AgentCore-Runtime-V2), so it would yield estimates.
  • guardrailConfig attaches a Bedrock guardrail; input redaction defaults on, output redaction off, and guardLatestUserMessage evaluates only the newest user turn rather than the whole history.
  • Also documented: agent-level structured output (structuredOutputSchema, Zod), reasoning via additionalRequestFields.thinking.budget_tokens, and troubleshooting for CRIS-style model-id errors.
  • The TypeScript SDK applies a default requestTimeout of 120 000 ms because the underlying AWS SDK defaults to 0 (disabled), which lets a stuck connection hang forever. The timeout measures stream inactivity, so a long-thinking model can trip it.
  • IAM: bedrock:InvokeModelWithResponseStream for streaming, bedrock:InvokeModel otherwise.

Tools

  • tool({ name, description, inputSchema, callback }) with a Zod schema — matches what Component-Agent-Runtime already does.
  • Tool calls from one assistant turn run concurrently by default (toolExecutor: 'concurrent'); 'sequential' is available when a later tool depends on an earlier one's side effect. Concurrency only happens when the model returns several tool-use requests in a single response.
  • Per-tool event order is preserved in both modes: BeforeToolCallEvent → ToolStreamUpdateEvent* → AfterToolCallEvent → ToolResultEvent. The hook-events diagram draws the last two reversed, so test before relying on either order.
  • Every tool — custom, community or vended — runs with the host process's permissions. The docs say to audit each one.
  • Vended tools ship at @strands-agents/sdk/vended-tools/*.
  • Custom tool executors are not yet supported (strands-agents/harness-sdk#762).

Shipped in 1.19.0, unused by us

The pinned package exports far more than Component-Agent-Runtime imports — listed from its package.json exports, for the architecture review:

Area Subpaths under @strands-agents/sdk/
Plugins vended-plugins/skills, context-offloader, context-injector, goal
Interventions vended-interventions/hitl, steering, cedar. The core API (InterventionHandler, InterventionActions) is exported from the root, but the action types are not. See Source-Strands-Decider
Tools vended-tools/ shell, bash, file-editor, http-request, web-fetch, notebook, sleep, handoff-to-user
Memory stores vended-memory-stores/bedrock-knowledge-base, file-memory-store
Storage and search storage, session/s3-storage, storage/search/bm25, storage/search/qmd
Sandboxes sandbox, sandbox/docker, sandbox/ssh
Other multiagent, a2a, telemetry, experimental, models for Anthropic, OpenAI, Google, Vercel and routing

The hook catalog also exposes streaming events — ModelStreamUpdateEvent, ContentBlockEvent, ModelMessageEvent, ToolStreamUpdateEvent — that an SSE handler would map to client events if live streaming lands (#45).

Optional MCP setup

The TypeScript quickstart's uvx strands-agents-mcp-server is an optional coding-assistant MCP server using stdio, not a Strands runtime dependency. Keep it out of repo-shared configs, which remain HTTP-only. Personal/session use is allowed after the dependency, permission, credential, data-sharing, and cost review in Guide-MCP-Servers and constitution P11. Recorded in Gotchas.

The quickstart's quickest credential path is a Bedrock API key in AWS_BEARER_TOKEN_BEDROCK. That is a long-lived bearer secret, so it needs a P11 review before anyone follows it; P11's temporary-credential paths work unchanged.

Version drift found

Decision-Strands-SDK cites 1.4.0 (plan) and 1.15.0 (research R15). packages/agent/package.json actually pins 1.19.0, which is still the latest release. The SDK requires Node.js 22+ (engines.node >=22.0.0).

See also: Source-Strands-Harness-Docs, Decision-Strands-SDK, Component-Agent-Runtime, Index.

Clone this wiki locally