-
Notifications
You must be signed in to change notification settings - Fork 0
[rig-claude] Improve Claude dynamic-workflow compatibility for rig #449
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -237,6 +237,42 @@ describe("dynamic-workflow parity", () => { | |
| }); | ||
| }); | ||
|
|
||
| it("emits one warning event when the warnAgents threshold is crossed", async () => { | ||
| // Maps to the Claude dynamic workflow session-level advisory warning when many | ||
| // agents are scheduled; lets callers detect runaway fan-out before hitting maxAgents. | ||
| const worker = fakeAgent<number, number>("worker", (value) => value); | ||
| const events: WorkflowEvent[] = []; | ||
| const definition = workflow({ | ||
| meta: { name: "warn", description: "warnAgents threshold" }, | ||
| body: ({ call, pipeline }) => pipeline([1, 2, 3], (value) => call(worker, value)), | ||
| }); | ||
|
|
||
| await runWorkflow(definition, { | ||
| limits: { warnAgents: 2 }, | ||
| onEvent: (event) => events.push(event), | ||
| }); | ||
| const warnings = events.filter((event) => event.type === "warning"); | ||
| expect(warnings).toHaveLength(1); | ||
| expect(warnings[0]).toMatchObject({ type: "warning", message: expect.stringContaining("2") }); | ||
| }); | ||
|
|
||
| it("call.json accepts a non-object schema (s.enum) — rig advantage over Claude dynamic workflows", async () => { | ||
| // Claude dynamic workflows only support object schemas in agent(prompt, { schema }). | ||
| // rig's call.json accepts any s.* schema: s.enum, s.array, s.string, etc. | ||
| configureAgent(() => ({ | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [/tdd] 💡 Suggested fixAdd cleanup, matching the pattern used in it("call.json accepts a non-object schema...", async () => {
const originalFactory = /* capture before */ undefined;
configureAgent(() => ({ ask: async () => high, close: async () => {} }));
// ... test body ...
// reset at the end, or use afterEach in a describe block
});Or wrap this test (and the |
||
| ask: async () => '"high"', | ||
| close: async () => {}, | ||
| })); | ||
|
|
||
| const definition = workflow({ | ||
| meta: { name: "enum-schema", description: "non-object schema in call.json" }, | ||
| body: ({ call }) => | ||
| call.json("Classify priority.", s.enum("high", "medium", "low")), | ||
| }); | ||
|
|
||
| await expect(runWorkflow(definition)).resolves.toBe("high"); | ||
| }); | ||
|
|
||
| it("runs a nested workflow on the shared limiter, budget, and events", async () => { | ||
| let active = 0; | ||
| let peak = 0; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[/tdd] The
stringContaining("2")assertion is weak — it would pass for any message containing the digit2. The test should pin the exact message string emitted by the runtime to be a true executable spec.💡 Suggested assertion
This matches the literal string in
rig.ts:`Workflow scheduled more than ${warnAgents} agents.`