Skip to content

feat(agents): ALS access API#1001

Closed
dmmulroy wants to merge 9 commits intomainfrom
feat/agent-context-lifecycle
Closed

feat(agents): ALS access API#1001
dmmulroy wants to merge 9 commits intomainfrom
feat/agent-context-lifecycle

Conversation

@dmmulroy
Copy link
Collaborator

@dmmulroy dmmulroy commented Feb 26, 2026

wip

@changeset-bot
Copy link

changeset-bot bot commented Feb 26, 2026

🦋 Changeset detected

Latest commit: 00f9587

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
agents Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dmmulroy dmmulroy force-pushed the feat/agent-context-lifecycle branch from d0dea4a to aa2a648 Compare February 26, 2026 14:39
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 26, 2026

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/agents@1001
npm i https://pkg.pr.new/cloudflare/agents/@cloudflare/ai-chat@1001
npm i https://pkg.pr.new/cloudflare/agents/@cloudflare/codemode@1001
npm i https://pkg.pr.new/cloudflare/agents/hono-agents@1001

commit: 00f9587

@dmmulroy dmmulroy marked this pull request as ready for review February 26, 2026 15:04
@dmmulroy dmmulroy marked this pull request as draft February 26, 2026 16:22
Enable per-entry-point context create/destroy around the SDK ALS so tracing/auth metadata can flow without a second ALS. Add runtime + type tests for request/websocket/schedule/queue/method context behavior.
Wire close/alarm through withContext, tighten context typing helpers, and align tests/docs/changeset with onContextStart/onContextEnd.
@dmmulroy dmmulroy force-pushed the feat/agent-context-lifecycle branch from 5156d7b to 8a1ea48 Compare February 26, 2026 20:04
@dmmulroy dmmulroy marked this pull request as ready for review February 26, 2026 20:07
Replace Agent.withContext with module-local runWithContext helper and update design docs to avoid exposing unstable orchestration surface.
@dmmulroy dmmulroy marked this pull request as draft February 26, 2026 21:06
Replace onContextStart/onContextEnd methods with declarative
context = new AgentContext(this, { onStart, onClose }). Constructor
returns Proxy that reads from ALS; hooks stored in WeakMap.

- Remove currentContext getter, context IS the runtime value
- Remove AgentContext<T> interface, phantom brand, hasOnEnd
- AgentContextOf<T> = T["context"] (no conditional types)
- onEnd renamed to onClose
- Preserve type AgentContext = DurableObjectState for compat
@dmmulroy dmmulroy changed the title feat(agents): add lifecycle context hooks for ALS feat(agents): declarative AgentContext class with Proxy-based ALS access Feb 26, 2026
@dmmulroy dmmulroy changed the title feat(agents): declarative AgentContext class with Proxy-based ALS access feat(agents): ALS access API Feb 27, 2026
@dmmulroy dmmulroy closed this Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant