Repository navigation
Durable Atomic sessions and workflow runs - #77045
lavaman131 wants to merge 7 commits into
Conversation
| }); | ||
| } | ||
| writeConfig("mcp.json", mcp); | ||
| const resumed = process.env.GH_AW_DURABLE_RESUMED === "true"; |
| const actionsDir = path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions'); | ||
| const { validateFiles } = require(path.join(actionsDir, 'durable_files.cjs')); | ||
| validateFiles({ core }); | ||
| - name: Upload durable checkpoint artifact |
| GH_AW_ATOMIC_STORAGE_ADAPTER: /tmp/gh-aw/atomic-storage/node_modules/@bastani/atomic-storage-libsql/libsql.js | ||
| GH_AW_ATOMIC_STORAGE_STAGING: /tmp/gh-aw/atomic-storage-staging.json | ||
| durable: | ||
| files: |
Save Atomic sessions, workflow journals, and run-scoped workflow artifacts under /tmp/gh-aw/agent/atomic-store on every run, declare behaviors.durable in shared/atomic.md so engine.durable restores that store and continues the saved root session, enable engine.durable on smoke-atomic, and add opt-in libSQL storage (@bastani/[email protected]) for Turso or self-hosted sqld.
0c2f13a to
149cb7a
Compare
| } finally { | ||
| try { | ||
| const brokerPid = Number(readFileSync(join(agentDir, "intercom", "broker.pid"), "utf8").trim()); | ||
| if (Number.isInteger(brokerPid) && brokerPid > 0) process.kill(brokerPid, "SIGTERM"); |
There was a problem hiding this comment.
🟡 Changes recommended
Dependency release-age protection is disabled, while colliding storage keys and missing exact session IDs can expose or resume another repository’s or workflow’s saved conversation.
5 open issues
Restore the release-age cooldown for adapter installs · New Persist and require the exact session ID for external continuation · New Use collision-resistant storage namespaces per repository · New Match the adapter version to the configured CLI version · New Prepare Atomic prompts when restoring history · New
What changed in this PR
Adds persistent session and workflow storage to the experimental Atomic engine, building on gh-aw’s durable checkpoint support and offering optional libSQL storage beyond artifact retention.
Changes:
- Save local sessions, workflow journals, run artifacts, and root session IDs for checkpoint-based continuation.
- Add optional Turso or self-hosted
sqldstorage, credential staging, and setup documentation. - Enable durable mode for the Atomic smoke workflow and expand regression coverage.
| File | Description |
|---|---|
pkg/workflow/atomic_workflow_test.go |
Tests storage configuration, staging, durable continuation, redaction, and validation. |
docs/src/content/docs/reference/third-party-agent.md |
Documents Atomic persistence, external storage setup, and security considerations. |
.github/workflows/smoke-atomic.md |
Enables durable checkpoints with seven-day retention. |
.github/workflows/smoke-atomic.lock.yml |
Regenerates smoke execution with durable checkpoints and storage plumbing. |
.github/workflows/shared/atomic.md |
Implements local persistence, session continuation, and optional external storage. |
.github/workflows/engine-conformance-atomic.lock.yml |
Regenerates conformance execution with storage plumbing, without durable mode. |
.changeset/patch-atomic-durable-sessions-and-storage.md |
Records the Atomic persistence and external-storage additions as a patch release. |
Review effort: Max (auto)
| if (/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/.test(recordedSessionId)) { | ||
| sessionArgs.push("--session", recordedSessionId); | ||
| } else { | ||
| sessionArgs.push("--continue"); |
| url: rawUrl, | ||
| token: rawToken, | ||
| namespace, | ||
| prefix: `gh_aw_${repository.toLowerCase().replace(/[^a-z0-9_]/g, "_")}`, |
| const install = spawnSync( | ||
| "npm", | ||
| ["install", "--prefix", "/tmp/gh-aw/atomic-storage", "--ignore-scripts", "--no-audit", "--no-fund", "@bastani/[email protected]"], | ||
| { stdio: "inherit" } | ||
| ); |
| if (resumed && !forwardedArgs.some(arg => ["--session", "--session-id", "--continue", "-c", "--no-session"].includes(arg))) { | ||
| const recordedSessionId = existsSync(sessionIdPath) ? readFileSync(sessionIdPath, "utf8").trim() : ""; | ||
| if (/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/.test(recordedSessionId)) { | ||
| sessionArgs.push("--session", recordedSessionId); |
|
@copilot run pr-finisher skill |
Co-authored-by: pelikhan <[email protected]>
|
@copilot atomic should not install additional packages in the setup script. It should be define in the declarative yaml so that the compiler can instal these packages as part of installing the agent |
|
@copilot there security implications to this. In particular, data is escaping the sa bd box without staging and the threat detection is coming too later to stop malicious session from polluting the database. This feature must be an error in strict mode and a warning in normal compilation. |
Co-authored-by: pelikhan <[email protected]>
Co-authored-by: pelikhan <[email protected]>
Addressed in
Addressed in |
Co-authored-by: pelikhan <[email protected]>
|
@copilot extend the declarative agentic engine syntax to support "durable-packages" to allow declaring additional packages that need to be installed when durable is enabled. Apply to atomic. |
Co-authored-by: pelikhan <[email protected]>
Added |
|
🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering. Structured data{
"completed_task": 0,
"head": "7c1b8abc84d2fe49d3fee50cdefbe0b9efbe3ba0",
"kind": "requested",
"schema_version": "1",
"state": "596d233c3430acb34182a69d5154159f0a98267f4435ce498aeea398d8da01da",
"work": [
"20c5fb9e2e37672daf5b7271dae9c95ff59f03cf41d0cde5ac7e2acc9456d2d1"
],
"workflow": "pr-sous-chef"
}
|
# Conflicts: # .github/workflows/engine-conformance-atomic.lock.yml # .github/workflows/smoke-atomic.lock.yml Co-authored-by: gh-aw-bot <[email protected]>
|
Superseded by #77253 and #77262, which are small independent PRs against
Closing in favor of those PRs. |


cc @pelikhan
Bottom of stack #77068 (#77045 → #77052). #77020 has merged.
Sessions and workflow runs saved on every run
--no-sessionfromshared/atomic.md. Every run now writes Atomic's sessions (sessions.sqlite), workflow journal (journal.sqlite), run-scoped workflow artifacts (runs/viaATOMIC_WORKFLOW_ARTIFACT_DIR), and recorded root session ID (session-id, mode0600) under/tmp/gh-aw/agent/atomic-storerather than relying on the parent of the temporary agent directory.history://share/tmp/gh-aw/agent/atomic-storewhile local Intercom stays off (intercom: offinatomic storage status), avoiding an idle SQLite broker poll when no shared database is configured.Artifact-backed durable mode (
behaviors.durable)behaviors.durableinshared/atomic.mdwithfiles: [/tmp/gh-aw/agent/atomic-store]and matching execution and harness configuration.internal = 0) session ID into/tmp/gh-aw/agent/atomic-store/session-id(0600), ignoring child subagent and workflow-stage sessions (internal = 1).GH_AW_DURABLE_RESUMED=true, the harness passes--session <id>to continue that saved root session (--continueif nosession-idfile is present). Interrupted Atomic workflow runs remain in the restoredjournal.sqliteandruns/folder for the agent to inspect or resume with theworkflowtool; the harness does not auto-resume workflow runs.durable: { retention-days: 7 }explicitly onsmoke-atomic.mdfor now (a separate compiler PR adds an engine-definition default).engine-conformance-atomic.mdomitsengine.durablebecausevalidateEngineDurablerejectswork-queueworkers (tools.work-queue.worker: true).Optional Turso and self-hosted
sqldguide and plumbingsqldserver indocs/src/content/docs/reference/third-party-agent.mdwhen runs need history past artifact expiry, local inspection from a developer machine (history://,/workflow status,/resume), cross-machine takeover of timed-out workflow runs, or Intercom multi-node routing between concurrent runners.Stage Atomic external storagepre-agent-stepsstep readssecrets.ATOMIC_STORAGE_URLandsecrets.ATOMIC_STORAGE_TOKENfrom stepenv:. WhenATOMIC_STORAGE_URLis empty, it removes any stale staging file and exits 0 without runningnpm. Otherwise it masks the values, installs@bastani/[email protected](NPM_CONFIG_IGNORE_SCRIPTS=true,NPM_CONFIG_MIN_RELEASE_AGE=0, pinned to matchengine.versionand enforced by test), and writes/tmp/gh-aw/atomic-storage-staging.json(0600).ATOMIC_STORAGE: "on"(plus optionalATOMIC_STORAGE_NAMESPACE) inengine.envand add the database host tonetwork.allowed./tmp/gh-aw/atomic-storage-staging.jsonbefore spawning Atomic (even whenATOMIC_STORAGEis unset,"off", or validation fails), registers secrets insensitiveValuesbefore any log or error path, validates the URL (libsql:,https:,wss:, orhttp:, rejecting userinfo andauthTokenquery parameters), requires a token forlibsql:/https:/wss:, writesstorage-token(0600) in the private agent directory, and writes top-levelstoragewith sanitized prefixgh_aw_<owner>_<repo>. On exit, if the run started an Intercom broker in the temporary agent directory, the harness sendsSIGTERMtobroker.pidbefore removingagentDir.Compatibility and security notes
ATOMIC_STORAGE: "on"never install or load the external adapter unlesssecrets.ATOMIC_STORAGE_URLis set in the repository, and even then they unlink the staging file before Atomic starts and keep using/tmp/gh-aw/agent/atomic-store.storage-token), and anyone with the database token can read saved sessions and workflow runs; scope tokens to one database and rotate them regularly. Unreachable databases fail closed without falling back to a temporary store.--approveloads.atomic/settings.json(restored from the base branch before the agent starts), a repository's ownstorage,sessions.storage, orworkflows.journalsetting in.atomic/settings.jsonoverrides the harness's store for sessions and workflow runs (while Intercom continues using globalstorage). Leave those keys out of.atomic/settings.jsonwhen using gh-aw durable sessions orATOMIC_STORAGE.smoke-atomic.lock.ymlandengine-conformance-atomic.lock.ymladdsATOMIC_STORAGE_URLandATOMIC_STORAGE_TOKENto the manifest secret inventory viashared/atomic.md'sStage Atomic external storagepre-agent step. Both are bound only in stepenv:, excluded from the AWF container environment viaexcluded-env, masked before adapter installation, staged0600only when non-empty, and unlinked by the harness before Atomic spawns. No new GitHub Actions or container images were added.Validation
gh-aw compile smoke-atomic engine-conformance-atomic daily-declarative-engine-improver --validatepasses (3 succeeded).go test ./pkg/workflow -run Atomic -count=1andGH_AW_ATOMIC_TEST_CLI=/fast/tmp/smoke-0979/prefix/bin/atomic go test ./pkg/workflow -run Atomic -count=1pass, including unit tests for adapter-version parity,pre-agent-stepsstaging, local store paths, durable session-ID recording and continuation, Turso/sqldsettings generation, staging unlinking, secret redaction, and input rejections.@bastani/[email protected]and@bastani/[email protected]:atomic_harness.cjsagainst a local mock OpenAI server, verifiedsessions.sqliteandsession-id(0600) in/tmp/gh-aw/agent/atomic-store, ranactions/setup/js/durable_files.cjs(stageFiles->validateFiles->restoreFiles), and ran turn 2 withGH_AW_DURABLE_RESUMED=true; verified turn 2's LLM request included turn 1's user prompt and assistant response and appended to the samesession_sessionsrow (message_count: 6)..atomic/settings.json: Started a localsqldcontainer (ghcr.io/tursodatabase/libsql-server), installed@bastani/[email protected]with the exactnpm installcommand, ran two invocations throughatomic_harness.cjswithATOMIC_STORAGE=onandGITHUB_REPOSITORY=Owner/My-Repo.name, and queriedsqlddirectly to confirm both sessions ingh_aw_owner_my_repo_namesession_sessions. Verifiedatomic storage status,atomic intercom status, andbroker.log(Intercom multi-node routing is on (adapter ..., prefix gh_aw_owner_repo)), and verified.atomic/settings.jsonprecedence both without and with a repositorystoragekey under--approve.actions/upload-artifact/restoreCheckpointagainst live GitHub Actions APIs) and a live remotelibsql://*.turso.iocloud endpoint over TLS/WebSocket.