Repository navigation
feat(mail): the agent event loop consumes the per-message delivery API (cli#617 slice c) #663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
cbe67de
feat(mail): the agent event loop consumes the per-message delivery AP…
tps-flint 67cd797
round: address the review verdict (Codex fix round)
tps-flint 5fbc3cb
round: address the review verdict (Codex fix round)
tps-flint 4c77bbd
round: address the review verdict (Codex fix round)
tps-flint aa6fbae
round: address the review verdict (Codex fix round)
tps-flint 6dca460
Merge branch 'main' into feat/617c-event-loop-delivery
tps-flint ce3ccdf
fix(mail): the event loop logs a settlement refusal reason when its d…
tps-flint 7a03cb1
test(mail): the refused-read lane assertion matches a mail.receive ev…
tps-flint 3d546b2
test(cli): state the event-log helper's contract without an over-broa…
tps-flint 022af71
fix(mail): bound a stopped event loop's settlement retries (cli#617 s…
tps-flint 4db46ed
docs(mail): the slice c fragment bounds settlement retries after a st…
tps-flint 6b1f892
docs(mail): drop an over-broad shutdown claim from the slice c fragme…
tps-flint 2124290
round: address the review verdict (Codex fix round)
tps-flint d8dd394
round: address the review verdict (Codex fix round)
tps-flint File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
.changelog/unreleased/changed-617-slice-c-event-loop-delivery.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| - **The agent event loop processes one mail delivery at a time (Refs #617, slice c).** | ||
|
|
||
| Handler completion requests finalization; a turn-limit return or thrown | ||
| handler requests release. Deferred finalization and release are retried on | ||
| the same delivery. Deadline quarantine requires the mailbox lock and storage | ||
| to become available. A failed storage operation can leave the durable transition | ||
| uncertain. A stop prevents | ||
| the next `deliverNext()` call; a check already waiting can return a delivery, | ||
| which the loop processes and attempts to settle before shutdown removes the | ||
| PID file. Deferred settlement is retried; a stop bounds the retries, and the | ||
| last deferral or refusal is logged. Any refusal can leave the intent pending, | ||
| blocking that message until resolved. | ||
|
|
||
| A handler that never returns cannot reach the presentation or deadline checks. | ||
|
|
||
| A committed unfinished hand-over can be re-presented after a kill when | ||
| recovery can verify it. A durably finalized delivery is not presented again. | ||
| Delivery API consumers receive a JSON-encoded | ||
| `[canonical mailbox path, messageId]` key, stable across presentations at that path. |
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // event-loop-child.mjs — cli#617 slice (c) test helper. | ||
| // | ||
| // Runs EventLoop with MailClient; the provider marks handler entry and waits. | ||
| // | ||
| // argv: <mailDir> <agentId> | ||
| // env: TPS_FROM, TPS_SEED, TPS_MARKER, TPS_WORKSPACE | ||
| import { mkdirSync, writeFileSync } from "node:fs"; | ||
| import * as ed from "@noble/ed25519"; | ||
| import { MailClient } from "../../src/io/mail.js"; | ||
| import { EventLoop } from "../../src/runtime/event-loop.js"; | ||
|
|
||
| const [mailDir, agentId] = process.argv.slice(2); | ||
| const from = process.env.TPS_FROM; | ||
| const seed = Buffer.from(process.env.TPS_SEED, "base64"); | ||
| const workspace = process.env.TPS_WORKSPACE; | ||
| mkdirSync(workspace, { recursive: true }); | ||
|
|
||
| const client = new MailClient(mailDir, undefined, agentId, { | ||
| async getAgent(name) { | ||
| return name === from ? { publicKey: Buffer.from(ed.getPublicKey(seed)) } : null; | ||
| }, | ||
| }); | ||
|
|
||
| const provider = { | ||
| async complete() { | ||
| writeFileSync(process.env.TPS_MARKER, "in-handler"); | ||
| await new Promise(() => {}); // spin until SIGKILL | ||
| }, | ||
| }; | ||
|
|
||
| const config = { | ||
| agentId, | ||
| name: "loop-child", | ||
| mailDir, | ||
| memoryPath: `${workspace}/mem.jsonl`, | ||
| workspace, | ||
| llm: { provider: "test", model: "test-model" }, | ||
| contextWindowTokens: 8000, | ||
| maxToolTurns: 50, | ||
| }; | ||
|
|
||
| const loop = new EventLoop({ | ||
| config, | ||
| memory: { append: async () => {} }, | ||
| context: {}, | ||
| provider, | ||
| tools: { list: () => [], execute: async () => ({ content: "ok" }) }, | ||
| }); | ||
|
|
||
| await loop.runDeliveries(client); |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.