Skip to content

feat(kitchen-sink): add mock agentic loop#4891

Closed
NathanFlurry wants to merge 1 commit intomock-agentic-loop/rivetkit-gateway-bypass-clientfrom
mock-agentic-loop/kitchen-sink-example
Closed

feat(kitchen-sink): add mock agentic loop#4891
NathanFlurry wants to merge 1 commit intomock-agentic-loop/rivetkit-gateway-bypass-clientfrom
mock-agentic-loop/kitchen-sink-example

Conversation

@NathanFlurry
Copy link
Copy Markdown
Member

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link
Copy Markdown
Member Author

NathanFlurry commented May 3, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 3, 2026

PR #4891 Review: feat(kitchen-sink): add mock agentic loop

Overview

Adds a mock agentic loop example consisting of:

  • Actor (src/actors/testing/mock-agentic-loop.ts): simulates LLM inference by inserting one row per second into SQLite and streaming progress over WebSocket
  • Driver script (scripts/mock-agentic-loop.ts): connects via raw WebSocket, drives inference requests, verifies progress ordering, and periodically POSTs sleep keepalives
  • Registry registration and a change to serverlessPoolConfig defaults

The overall design is solid for a stress/smoke test harness. A few items worth addressing.


Issues

Cross-connection concurrency gap (actor side)

The activeInference guard is declared inside the onWebSocket closure, making it per-connection rather than per-actor. If two WebSocket connections to the same actor both send infer with the same requestId, the opening DELETE FROM mock_agentic_entries WHERE request_id = ? from one coroutine can race with the INSERT loop of the other, producing corrupt verification results.

In the current script, requestId is always a fresh UUID so this will not trigger in normal use. A simple fix is to promote the guard to actor-level state (outside onWebSocket), or document the limitation.

serverlessPoolConfig default change is kitchen-sink-wide

The bumped defaults (requestLifespan 30 s to 900 s, drainGracePeriod 5 s to 900 s) apply to every actor routed through serverlessPoolConfig, not just the mock agentic loop. Bumping drainGracePeriod from 5 s to 15 min is a large behavioural change for all existing kitchen-sink actors. If the long lifespan is only needed for this actor, consider per-actor pool overrides or add a comment explaining the intent.

SLEEP_INTERVAL_MS is not env-configurable

Every other timing parameter has a numberFromEnv override, but SLEEP_INTERVAL_MS = 120_000 is hardcoded. This inconsistency will be confusing for anyone trying to tune the test parameters.


Minor / Style

Magic number 1 in send (actor file, readyState !== 1): use WebSocket.OPEN or a named constant instead of the bare literal.

started message defined but never consumed: The ServerMessage union includes { type: "started" ... } and the actor sends it, but the client script immediately starts waiting for progress/done and silently drops the started frame. A short comment noting this is intentional would help future readers.

history response grows unbounded: The actor sends the full entries array with no limit. After a long soak run the table can grow large. Consider a row cap, or drop entries from the response if totalRows alone suffices for the diagnostic.


What is well done

  • canHibernateWebSocket: false is the right call given the active in-memory inference state, and c.keepAwake(inference) correctly prevents the actor from sleeping mid-inference.
  • Errors are sent back over the WebSocket rather than silently swallowed, which is valuable for remote debugging.
  • The RawSession waiter queue is clean and handles reconnect correctly.
  • Input validation (positiveInteger, stringValue, numberFromEnv) at both actor and script boundaries is thorough.
  • Verification via the action endpoint (a separate code path from WebSocket) cross-checks that SQLite persistence is correct, which is the core value of this test.

@NathanFlurry NathanFlurry changed the base branch from mock-agentic-loop/wire-sqlite-preload-hints to graphite-base/4891 May 4, 2026 00:36
@NathanFlurry NathanFlurry force-pushed the graphite-base/4891 branch from f4963e9 to 36860a0 Compare May 4, 2026 00:36
@NathanFlurry NathanFlurry force-pushed the mock-agentic-loop/kitchen-sink-example branch from 906a529 to 2e3e511 Compare May 4, 2026 00:36
@NathanFlurry NathanFlurry changed the base branch from graphite-base/4891 to 05-02-fix_pegboard_restore_hibernating_request_ids May 4, 2026 00:37
@NathanFlurry NathanFlurry changed the base branch from 05-02-fix_pegboard_restore_hibernating_request_ids to graphite-base/4891 May 4, 2026 00:44
@NathanFlurry NathanFlurry force-pushed the mock-agentic-loop/kitchen-sink-example branch from 2e3e511 to 2261075 Compare May 4, 2026 00:44
@NathanFlurry NathanFlurry changed the base branch from graphite-base/4891 to mock-agentic-loop/rivetkit-gateway-bypass-client May 4, 2026 00:44
@NathanFlurry NathanFlurry force-pushed the mock-agentic-loop/rivetkit-gateway-bypass-client branch from 78c0c4e to a0fd0c0 Compare May 4, 2026 00:54
@NathanFlurry NathanFlurry force-pushed the mock-agentic-loop/kitchen-sink-example branch from 2261075 to f116193 Compare May 4, 2026 00:54
@NathanFlurry NathanFlurry changed the base branch from mock-agentic-loop/rivetkit-gateway-bypass-client to graphite-base/4891 May 4, 2026 02:59
@NathanFlurry NathanFlurry force-pushed the graphite-base/4891 branch from a0fd0c0 to e4d176d Compare May 4, 2026 03:01
@NathanFlurry NathanFlurry force-pushed the mock-agentic-loop/kitchen-sink-example branch from f116193 to 0290633 Compare May 4, 2026 03:01
@NathanFlurry NathanFlurry changed the base branch from graphite-base/4891 to mock-agentic-loop/rivetkit-gateway-bypass-client May 4, 2026 03:01
@NathanFlurry NathanFlurry marked this pull request as ready for review May 4, 2026 03:32
@NathanFlurry NathanFlurry force-pushed the mock-agentic-loop/rivetkit-gateway-bypass-client branch from e4d176d to fc57d3c Compare May 4, 2026 04:13
@NathanFlurry NathanFlurry force-pushed the mock-agentic-loop/kitchen-sink-example branch from 0290633 to 34b5931 Compare May 4, 2026 04:13
@NathanFlurry
Copy link
Copy Markdown
Member Author

Landed in main via stack-merge fast-forward push. Commits are in main; closing to match.

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