fix: initialize EmailAgent before the first auto-draft - #65
Open
Bortlesboat wants to merge 1 commit into
Open
Bortlesboat wants to merge 1 commit into
Bortlesboat wants to merge 1 commit into
Conversation
Signed-off-by: Bortlesboat <169967362+Bortlesboat@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #57.
The first inbound email can reach an EmailAgent that has never been opened through the UI. Getting the Durable Object stub directly skips the Agents/Partyserver naming handshake, so its first
/onNewEmailrequest fails.Resolve the stub with
getAgentByNameand keep both initialization and the draft request insidectx.waitUntil. Initialization failures use the existing error handler after the email has been stored.Validation:
npm run typecheckandnpm run buildpass. A local harness bundles the real worker, PostalMime parser, and installed Agents/Partyserver SDK, replacing only Cloudflare runtime bindings with in-memory stubs. It verifies the set-name request precedes/onNewEmail, the original draft payload is preserved, and a rejected naming request is logged without losing the stored message. The first-message assertion fails on the original code. No deployment, live email, or model request was used.