Building Headcount on AgentCore, TypeScript Only

Headcount, Part 3 of 3. A series on running a business function with a team of AI agents and one human owner. Part 1: I Can't Hire a Department for Every Product. Part 2: Trust Is Earned One Action at a Time.
The first two parts were about what Headcount does and why. This one is about how it's built, and about the spike I ran before writing any framework code.
Four constraints I set on day one
- TypeScript only. Agents, tools, infrastructure and CLI. No Python anywhere. I want one language, one toolchain and one set of tests.
- Serverless only. Nothing runs when nothing is happening. A department that works in a weekly cycle shouldn't pay for a server the rest of the week.
- CDK only. No resource gets created in the console.
- No dependency without an ADR. Every package is a decision, and decisions get written down.
The first one was a real risk. Most of the AgentCore examples I found were in Python. If AgentCore couldn't be driven from TypeScript, the whole stack had to change. More on that below.
The architecture

- Agents are written with the Strands Agents TypeScript SDK and each one runs in its own AgentCore Runtime. The Supervisor calls Specialists directly for short work and goes through the Task Board for long work.
- Tools are MCP tools behind AgentCore Gateway. Agents never hold a raw credential. AgentCore Identity brokers the OAuth tokens and API keys.
- State lives outside the agents. DynamoDB holds Tasks, Policies, the budget ledger and the audit index. S3 holds Artifacts. AgentCore Memory holds the lessons each cycle writes for the next one.
- Triggers come from EventBridge Scheduler for cycles, API Gateway for webhooks and the Slack app, and Task Board state changes. No agent runs in a loop waiting for work.
- Approvals pause a Step Functions workflow on a task token until I answer in Slack.
- Observability is AgentCore Observability, CloudWatch, and an append-only audit ledger. Every invocation, tool call, Task transition, approval and Action gets recorded, along with its cost.
The framework is one CDK stack, and each department instance gets its own.
Contracts between agents

There are no free-text hand-offs. Every Task is an envelope with the same fields in every department: who it's for, which contract and version, the goal, the inputs, references to context, constraints like deadline and budget, acceptance criteria, and an idempotency key.
Every result comes back in the same shape too: a status (succeeded, failed, needs input, blocked), references to the Artifacts it produced, a summary, a confidence score, the cost, and any proposed Actions.
Department-specific payloads are versioned schemas in a Contract Registry, validated when they're sent and again when they're received. Large content never goes through an agent's context. A blog draft goes to S3, and agents pass its URI and a short summary.
This is what lets the Supervisor review work against criteria it wrote down up front, instead of reading a paragraph and deciding whether it sounds finished.
The Task Board
Tasks move through eight states: pending, assigned, running, awaiting review, awaiting approval, done, failed, cancelled. Each transition emits an EventBridge event that triggers the next agent. A Task with dependencies can't be assigned until they're done, and a Task that runs past its timeout is failed and escalated to me.
Delivery is at least once, so every handler has to be idempotent. That's the same rule as Actions: retries must never double-publish or double-spend.
Rules the code has to keep

Before writing code I wrote a constitution for the repo. It's short, and changing any of it needs an approved ADR. The rule I expect to defend most often is the generic core: no marketing concept and no Henchly name can appear in the core package.
The test for it is on the roadmap. After the Henchly pilot, I'll scaffold a Finance department skeleton using only config and the template, and record every change it forces on the core. If the list is long, the core wasn't generic.
The spike: can AgentCore do this from TypeScript?
The question was narrow. Which AgentCore services can a TypeScript Strands agent use today, through which client, with no Python?
I deployed a small stack with CDK to a throwaway account, probed it, destroyed it, and did it again the next day. The answer was all four.
| Service | Verdict | How |
|---|---|---|
| Runtime | go | bedrock-agentcore app on the NODE_22 runtime, deployed as a code asset with no container |
| Memory | go | AWS SDK v3 data-plane client for short-term events |
| Gateway | go | Strands McpClient over the standard MCP transport, with a SigV4-signing fetch |
| Identity | go, with a caveat | CDK API-key credential provider, consumed by the Gateway target |
The Memory check wrote a random fact in one invocation and read it back in a fresh one, so it couldn't have come from conversation history. The Identity check confirmed the target received the key, while a separate script confirmed the key never showed up in the bundle, the prompt, the runtime definition or its logs.
What it cost to get there
Every one of these cost me a failed deploy or a failed probe, and the framework will hit all of them again.
- The runtime wants a
.jsentrypoint. CloudFormation rejects.mjsforNODE_22. Bundle tomain.jswith apackage.jsonthat says"type": "module". - A dependency loads its plugins in a way esbuild can't follow. The bundle builds fine and then fails at startup, and all AgentCore tells you is "Runtime initialization time exceeded". I fixed it with a small esbuild plugin that fails the build if the package changes shape.
- Two spaces in a header. CDK's default API-key prefix is
"Bearer "with a trailing space, and the Gateway adds its own. The target receivesBearer, two spaces, then the key, and any exact check fails. The Gateway reports it as "internal error". - Gateway errors hide the target's response. Both auth failures above surfaced as "internal error". You need the target's own logs, or a script that calls the Gateway without the model in the loop.
- Log groups outlive the stack. AgentCore creates the runtime's log groups itself, so
cdk destroyleaves them, prompts and replies included.
The finding I care most about
After the deploy, an adversarial review of the spike found something more important than any of the bugs above.
The Gateway construct's default service role has a trust statement with no source-account condition, and it can read every credential that AgentCore Identity holds in the account and region. Anyone who can pass that role to their own Gateway can read them all.
The Runtime's default role is also wider than it needs to be, and the default model grant covers every foundation model.
None of this is exotic. It's what you get when you accept construct defaults to make a demo work. The spike kept those defaults so its evidence stayed honest, and it only ever ran in an isolated account. The framework won't use them: every role gets built explicitly, and a synth test asserts its resources, not just its actions.
Two more rules came out of the same review. Memory keys must come from an authenticated identity, never from the request payload, or any caller can read any session. And anything recalled from memory is untrusted input, because a remembered instruction goes straight back into the model's context.
What's next

Five more decisions before framework code: the agent architecture, the contract envelopes, the Task Board, policy and autonomy budgets, and the package and instance config format. Then the framework core, with a clear finish line: a stub department with one echo Specialist runs a scheduled cycle end to end in a deployed account, through the Task Board, Policy, a Slack approval, the ledger, the audit trail and the kill switch.
After that comes Marketing, then the Henchly pilot. I'll write up the pilot with the real numbers, including the ones that don't look good.
Start from the beginning: Part 1, I Can't Hire a Department for Every Product.