Skip to content

Dispatch schedule runs through the session and turn HTTP APIs. - #517

Merged
heerambavi1998 merged 17 commits into
mainfrom
ha/schedule-session-turn
Aug 31, 2026
Merged

heerambavi1998 merged 17 commits into
mainfrom
ha/schedule-session-turn

Conversation

@heerambavi1998

@heerambavi1998 heerambavi1998 commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Get-or-create a session keyed by run id, then create a turn only when that session has none, using the same SDK client in standalone and the dedicated controller.
Also removes distributed entry point as that requires auth fixes now that we call actual APIs.

Changes

How was this tested?

Checklist

  • I have read the contributing guidelines
  • pnpm build, pnpm test, pnpm typecheck, pnpm lint:ci, and pnpm format:check pass locally
  • Tests added/updated where it makes sense
  • No hand-edits to generated code (packages/trueforge-sdk, .github/fern/openapi/openapi.json, docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge
  • Docs / .env.example updated if configuration or behavior changed

Note

Medium Risk
Changes how scheduled work is executed (real turns + idempotency races with schedule API) and relies on loopback HTTP with auth disabled; distributed controller deployment is no longer shipped as a separate binary entry.

Overview
Scheduled cron runs now execute through the same session/turn HTTP path as interactive agents, instead of logging a no-op when a run is due.

The schedule-dispatch loop uses @truefoundry/trueforge-sdk with auth: false against a configurable baseUrl. For each due run it get-or-creates a session via internal.sessions.getOrCreateByExternalId keyed by run id, then creates a user-message turn with the schedule task only when listTurns shows no existing turns—making redispatch safe after crashes or retries.

Controller wiring is refactored: createController / runController accept injected store, transactions, logger, and baseUrl; standalone main builds the controller with http://localhost:${PORT} and starts it after the HTTP server is listening so loopback calls succeed. The old standalone dist/controller entry and top-level Postgres bootstrap in src/controller.ts are removed (distributed controller process deferred until API auth is sorted).

Minor follow-ons: shared SESSION_EXTERNAL_ID_UQ constant for migrations/store, sdk:build on predev/pretest/pretypecheck, and unit tests for the dispatch client behavior.

Reviewed by Cursor Bugbot for commit 62f3e86. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot

changeset-bot Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 62f3e86

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

This PR includes changesets to release 1 package
Name Type
@truefoundry/trueforge Patch

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

Comment thread packages/trueforge/src/controller.ts Resolved
Comment thread packages/trueforge/src/controller.ts Resolved
Comment thread packages/trueforge/package.json Resolved
Base automatically changed from ha/session-external-id to main August 31, 2026 13:06
@heerambavi1998
heerambavi1998 force-pushed the ha/schedule-session-turn branch from 6789661 to 78ef2cf Compare August 31, 2026 13:06
Comment thread packages/trueforge/package.json Resolved
@heerambavi1998
heerambavi1998 force-pushed the ha/schedule-session-turn branch from bc7dd09 to b0b73df Compare August 31, 2026 15:16

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b0b73df. Configure here.

@heerambavi1998
heerambavi1998 merged commit 4ced8ef into main Aug 31, 2026
8 checks passed
@heerambavi1998
heerambavi1998 deleted the ha/schedule-session-turn branch August 31, 2026 16:02
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.

2 participants