Upgrade Flue to beta.6 and migrate tool API (TOO-186) - #123
Conversation
…O-186) - Bump @flue/runtime, @flue/cli, @flue/sdk to 1.0.0-beta.6 - Rename createAgent → defineAgent (deprecated in beta.6) - Migrate tool definitions: parameters → input, execute → run Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T8rBz41yaNYNbvrxBSiynt
Complete the @flue/runtime beta.6 migration:
- src/tools/{cdk,datadog,jaeger,loki,newrelic}.ts: parameters→input, execute→run
- src/tools/__tests__/*.test.ts (11 files): tool.execute({…})→tool.run({input:{…}}), tool.parameters→tool.input
- src/mcp-mode.ts: .parameters→.input, .execute(args)→.run({input:args})
- src/workflows/triage.ts: replace removed FlueContext<T>/init() pattern with
defineWorkflow + ActionContext (harness provided directly, payload→input schema)
All 1338 tests pass, typecheck clean.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T8rBz41yaNYNbvrxBSiynt
|
Warning Review limit reached
More reviews will be available in 48 minutes. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR bumps Flue package versions, migrates the Heimdall agent and triage workflow to ChangesFlue API migration
Sequence Diagram(s)Triage workflow sequenceDiagram
participant CLI
participant defineWorkflow
participant loadConfig
participant buildTriagePrompt
CLI->>defineWorkflow: run with --input JSON
defineWorkflow->>loadConfig: loadConfig()
defineWorkflow->>buildTriagePrompt: buildTriagePrompt({ ...input, slos })
defineWorkflow-->>CLI: { report: response.text }
MCP tool call sequenceDiagram
participant MCPClient
participant mcpMode
participant safeParse
participant toolRun
MCPClient->>mcpMode: CallTool request
mcpMode->>safeParse: validate tool.input
safeParse-->>mcpMode: validation result
mcpMode->>toolRun: run({ input: validatedArgs })
toolRun-->>mcpMode: string or object result
mcpMode-->>MCPClient: text content
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request updates the codebase to align with the latest @flue/runtime (v1.0.0-beta.6) APIs. Key changes include replacing createAgent with defineAgent, migrating tool definitions from parameters and execute to input and run, and refactoring workflows to use defineWorkflow. Feedback suggests using v.nullish instead of v.optional in Valibot schemas for tool parameters to ensure that both null and undefined values from LLM providers are handled gracefully.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| input: v.object({ | ||
| context: v.pipe( | ||
| v.optional(v.string()), | ||
| v.description('Cluster context to query. Defaults to the configured/current context.'), | ||
| ), | ||
| }), |
There was a problem hiding this comment.
When defining tool parameters for LLM consumption using Valibot, prefer using v.nullish instead of v.optional to ensure that both null and undefined values passed by LLM providers are accepted gracefully without causing validation failures.
| input: v.object({ | |
| context: v.pipe( | |
| v.optional(v.string()), | |
| v.description('Cluster context to query. Defaults to the configured/current context.'), | |
| ), | |
| }), | |
| input: v.object({ | |
| context: v.pipe( | |
| v.nullish(v.string()), | |
| v.description('Cluster context to query. Defaults to the configured/current context.'), | |
| ), | |
| }), |
References
- When defining tool parameters for LLM consumption using Valibot, use v.nullish instead of v.optional to ensure that both null and undefined values passed by LLM providers are accepted gracefully without causing validation failures.
There was a problem hiding this comment.
Valid point — v.nullish is more defensive for LLM-supplied values that may pass null. However, this is the existing pattern used consistently across all 13 tool files (not introduced by this migration), so changing it here would be inconsistent. Leaving it for a dedicated follow-up PR that updates all tool schemas uniformly.
Generated by Claude Code
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 10a5b65f6f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ), | ||
| }), | ||
| execute: async ({ args, context }) => | ||
| run: async ({ input: { args, context } }) => |
There was a problem hiding this comment.
Wrap the new run callback when telemetry is enabled
When telemetry.enabled is true or HEIMDALL_TELEMETRY_FILE is set, src/agents/heimdall.ts still calls tool.execute.bind(t) inside wrapWithTiming, but this migration now returns tools with run instead of execute (as here). That makes agent startup throw before any prompt can run for telemetry-enabled deployments; the timing wrapper needs to wrap run({ input, signal }) and preserve the beta.6 tool shape.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch — fixed in e17befc. wrapWithTiming was using the old execute API instead of run({ input, signal }), which would have thrown on startup for any telemetry-enabled deployment. Updated to tool.run.bind(tool) and wrap the context argument through unchanged.
Generated by Claude Code
The telemetry timing wrapper was left on the old execute() API, which would
cause agent startup to throw for any telemetry-enabled deployment. Wrap
tool.run({ input, signal }) instead, matching the beta.6 ToolDefinition shape.
Caught by Codex P2 review on PR #123.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T8rBz41yaNYNbvrxBSiynt
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/workflows/triage.ts (1)
12-13: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueStale HTTP-exposure example.
The header comment still shows the old
export const route: WorkflowRouteHandlerpattern. Confirm this still applies under thedefineWorkflowdefault-export model; otherwise update the example to avoid misleading callers.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/workflows/triage.ts` around lines 12 - 13, The HTTP-exposure example in the header comment is stale and still shows the old named export pattern; verify how workflows are exposed with the current defineWorkflow default-export model used in triage.ts, and update the comment to reflect the actual supported route pattern or remove the example if it no longer applies. Use the triage workflow’s defineWorkflow/default export and route handler naming as the reference point so the documentation matches the implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/mcp-mode.ts`:
- Around line 197-200: The MCP request handler is not forwarding cancellation to
tool execution, so long-running work in `tool.run` cannot stop when the request
is aborted. Update the `setRequestHandler(..., async (request, extra) => ...)`
flow in `src/mcp-mode.ts` to pass `extra.signal` into the `tool.run` call
alongside `input: validatedArgs`, using the existing `tool.run` signature so
cancelled requests terminate promptly.
---
Nitpick comments:
In `@src/workflows/triage.ts`:
- Around line 12-13: The HTTP-exposure example in the header comment is stale
and still shows the old named export pattern; verify how workflows are exposed
with the current defineWorkflow default-export model used in triage.ts, and
update the comment to reflect the actual supported route pattern or remove the
example if it no longer applies. Use the triage workflow’s
defineWorkflow/default export and route handler naming as the reference point so
the documentation matches the implementation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ce53816f-9829-4c8c-ac97-f327a9e53cc6
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (27)
package.jsonsrc/agents/heimdall.tssrc/mcp-mode.tssrc/tools/__tests__/aws.test.tssrc/tools/__tests__/cdk.test.tssrc/tools/__tests__/datadog.test.tssrc/tools/__tests__/helm.test.tssrc/tools/__tests__/jaeger.test.tssrc/tools/__tests__/kubecost.test.tssrc/tools/__tests__/loki.test.tssrc/tools/__tests__/newrelic.test.tssrc/tools/__tests__/prometheus.test.tssrc/tools/__tests__/tools.test.tssrc/tools/__tests__/trivy.test.tssrc/tools/aws.tssrc/tools/cdk.tssrc/tools/datadog.tssrc/tools/helm.tssrc/tools/jaeger.tssrc/tools/kubeconfig.tssrc/tools/kubecost.tssrc/tools/kubectl.tssrc/tools/loki.tssrc/tools/newrelic.tssrc/tools/prometheus.tssrc/tools/trivy.tssrc/workflows/triage.ts
Pass extra.signal from setRequestHandler into tool.run({ input, signal })
so long-running tool calls can be cancelled when MCP clients abort requests.
Suggested by CodeRabbit in PR #123.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T8rBz41yaNYNbvrxBSiynt
Summary
Upgrades
@flue/cli,@flue/runtime, and@flue/sdkfrom beta.1/beta.2 to^1.0.0-beta.6and migrates all code to the new tool API introduced in beta.6.Breaking changes in beta.6:
ToolDefinition.parametersrenamed toToolDefinition.inputToolDefinition.execute(args, signal?)replaced byToolDefinition.run({ input, signal })createAgentdeprecated →defineAgent(backwards-compatible alias kept)FlueContext<T>removed from exports → replaced byActionContext<TInput>insidedefineWorkflowexport default defineWorkflow(...)instead ofexport async function run(...)Files changed:
package.json+package-lock.json: bump all three@flue/*packages to beta.6src/agents/heimdall.ts:createAgent→defineAgentsrc/tools/*.ts(13 files):parameters→input,execute→runsrc/mcp-mode.ts: updated.parameters/.execute()call sitessrc/tools/__tests__/*.test.ts(11 files):tool.execute({…})→tool.run({input:{…}}),tool.parameters→tool.inputsrc/workflows/triage.ts: replacedFlueContext<TriageOptions>/init()pattern withdefineWorkflow+ActionContext(harness provided directly, payload → typed valibot input schema)Test plan
npm run typecheck— clean (0 errors)npm test— 1338 tests pass across 62 test filesflue run triagestill works end-to-end against a real cluster🤖 Generated with Claude Code
https://claude.ai/code/session_01T8rBz41yaNYNbvrxBSiynt
Generated by Claude Code
Summary by CodeRabbit
Bug Fixes
--inputJSON and validate fields more consistently.Chores