Skip to content

Feat/sys tool/wait sleep - #10

Draft
ConnorIllingworth wants to merge 25 commits into
masterfrom
feat/sys-tool/wait-sleep
Draft

Feat/sys tool/wait sleep#10
ConnorIllingworth wants to merge 25 commits into
masterfrom
feat/sys-tool/wait-sleep

Conversation

@ConnorIllingworth

@ConnorIllingworth ConnorIllingworth commented Dec 11, 2025

Copy link
Copy Markdown
Collaborator

Description

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Refactoring

Checklist

  • Tests pass locally (pnpm test)
  • Build succeeds (pnpm build)
  • Changeset added (if needed - run pnpm changeset)
  • Updated relevant documentation

Notes

@vercel

vercel Bot commented Dec 11, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
kernl-docs Error Error Dec 12, 2025 6:19am
kernl-landing Error Error Dec 12, 2025 6:19am
kernl-registry Error Error Dec 12, 2025 6:19am

@ConnorIllingworth

Copy link
Copy Markdown
Collaborator Author

Modified scheduled_wakeups schema to not be reliant on llm/agent knowing the date.

Added Route Comments to working files.

This allows easier use with website-based chat agents. Due to them naming files the same thing.

EX: Claude will named them just index.ts index.ts.
This allows you to open it and read the top and see what file it is without looking at the actual file.

scheduled_wakeups
Added routes to working files so it's easier to chat with.
Introduces a new wakeup scheduling contract to kernl, including types and store interface. Adds PostgreSQL-backed implementation (PGWakeupStore) with codecs and SQL helpers for persisting, updating, and claiming scheduled wakeups. Updates package exports to expose the new API.
Introduces the WakeupStore interface to KernlStorage and implements an in-memory version (InMemoryWakeupStore) for managing scheduled wakeups. Updates the in-memory storage class to include wakeup management, supporting creation, retrieval, update, deletion, and claiming of due wakeups.
Introduces a new 'wakeup' system tool for scheduling thread wakeups, exposes it via the toolkit system, and ensures it is initialized and bound in the Agent class. Updates the wait tool's parameter schema and documentation for clarity, and exports the wakeup toolkit alongside memory in the tool index.
Updated the wait_until tool to require the runtime to pass an explicit thread_id parameter, rather than relying on agent-level scheduling for the current thread. The tool now schedules wakeups directly via the storage-backed wakeup store, improving clarity and decoupling from agent internals. Documentation and parameter schema were updated accordingly.
Scheduled wakeup records now use generated IDs, camelCase field names, and store runAt in epoch milliseconds to align with the NewScheduledWakeup domain type.
Refactored the system toolkit previously named 'wakeup' to 'sleep' for improved semantic clarity. Updated all relevant imports, exports, and documentation to reflect the new naming.
Updated the sleep tool to obtain threadId from the context instead of requiring it in parameters. Adjusted documentation and assertions accordingly, and ensured threadId is set in context during thread execution.
Introduces a new agent called 'Sleeper' that uses the wait_until tool to pause and wait as instructed. The agent is configured with OpenAI's GPT-5.1 model and has memory enabled.
Added the sleeper agent to the Kernl application by importing it and registering it alongside other agents. Also commented out the unused turbopuffer import.
Sleep saying Running.
Improves thread state management to distinguish between INTERRUPTIBLE and STOPPED states, ensuring correct behavior when threads are paused (e.g., sleeping). Updates the sleep system tool to use execute() for scheduling wakeups and reporting status, rather than requiresApproval, and enhances the thread event processing logic to better handle system tool interrupts and sleep events.
Introduces the WakeupScheduler class and related types to enable automated polling and processing of due wakeups. Integrates the scheduler into Kernl, allowing configuration via KernlOptions and exposing scheduler state and controls. This facilitates automatic resumption of sleeping threads based on scheduled wakeups.
Updated kernl dependency in package.json to use workspace reference. Enabled and started the scheduler in app.ts, and performed minor formatting cleanup in sleeper.ts.
Replaces the boolean scheduler option with an object specifying autoStart. Also comments out the explicit scheduler start call, likely to rely on the new autoStart behavior.
Deleted a TODO comment from packages/kernl/src/agent/index.ts, leaving the file empty.
Moved AGENTS.md to the .codex directory for better organization or to follow project structure conventions.
Renames `run_at_s` to `wakeup_at`, adds `sleep_for` to scheduled wakeups, and updates all related codecs, SQL, and store logic for consistency. Adds a migration to handle schema changes, backfill data, and update indexes. All timestamps are now stored in epoch seconds for stability and consistency.
Updated wakeup scheduling logic to prefer a new `sleepFor` (seconds) field over the legacy `runAt` (epoch ms) for specifying wakeup times. Adjusted in-memory store, sleep tool, and types to support both fields for backward compatibility, with `sleepFor` as the primary method going forward.
Removed support for run_at_s in the WaitParamsSchema and related logic, making delay_s a required parameter for specifying sleep duration. This streamlines the wait tool's interface and reduces complexity.
Introduces a new migration (000_enable_vector) that ensures the 'vector' extension is enabled in the database before other migrations are applied.
When a thread wakes up, a user message is appended to the thread indicating the sleep period is complete and the task should continue. This provides clearer context for thread resumption.
@ConnorIllingworth

Copy link
Copy Markdown
Collaborator Author

Rebased, up to date with main

@ConnorIllingworth

Copy link
Copy Markdown
Collaborator Author

Oh also recursive waits, did via user command for now

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