Skip to content

Upgrade Flue to beta.6 and migrate tool API (TOO-186) - #123

Merged
billzhuang merged 4 commits into
mainfrom
claude/zen-galileo-0kw1df
Jun 26, 2026
Merged

Upgrade Flue to beta.6 and migrate tool API (TOO-186)#123
billzhuang merged 4 commits into
mainfrom
claude/zen-galileo-0kw1df

Conversation

@billzhuang

@billzhuang billzhuang commented Jun 26, 2026

Copy link
Copy Markdown
Owner

Summary

Upgrades @flue/cli, @flue/runtime, and @flue/sdk from beta.1/beta.2 to ^1.0.0-beta.6 and migrates all code to the new tool API introduced in beta.6.

Breaking changes in beta.6:

  • ToolDefinition.parameters renamed to ToolDefinition.input
  • ToolDefinition.execute(args, signal?) replaced by ToolDefinition.run({ input, signal })
  • createAgent deprecated → defineAgent (backwards-compatible alias kept)
  • FlueContext<T> removed from exports → replaced by ActionContext<TInput> inside defineWorkflow
  • Workflow modules must export default defineWorkflow(...) instead of export async function run(...)

Files changed:

  • package.json + package-lock.json: bump all three @flue/* packages to beta.6
  • src/agents/heimdall.ts: createAgentdefineAgent
  • src/tools/*.ts (13 files): parametersinput, executerun
  • src/mcp-mode.ts: updated .parameters / .execute() call sites
  • src/tools/__tests__/*.test.ts (11 files): tool.execute({…})tool.run({input:{…}}), tool.parameterstool.input
  • src/workflows/triage.ts: replaced FlueContext<TriageOptions> / init() pattern with defineWorkflow + 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 files
  • Verify flue run triage still 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

    • Updated several built-in tools to work with the latest tool interface, improving reliability when running commands and queries.
    • Improved argument handling and validation for tool execution, reducing invalid input issues.
    • Updated the triage workflow to accept structured --input JSON and validate fields more consistently.
  • Chores

    • Bumped core package versions to newer beta releases.
    • Aligned agent setup with the latest initialization format.

claude added 2 commits June 26, 2026 01:34
…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
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@billzhuang, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5b7b9af2-dba8-4dc1-a8d7-6eb797af9999

📥 Commits

Reviewing files that changed from the base of the PR and between 10a5b65 and 1838872.

📒 Files selected for processing (2)
  • src/agents/heimdall.ts
  • src/mcp-mode.ts
📝 Walkthrough

Walkthrough

The PR bumps Flue package versions, migrates the Heimdall agent and triage workflow to defineAgent/defineWorkflow, updates tool definitions and MCP handling to input/run, and rewrites tool tests to call run({ input: ... }).

Changes

Flue API migration

Layer / File(s) Summary
Runtime entrypoints
package.json, src/agents/heimdall.ts, src/workflows/triage.ts
Package versions are bumped, heimdall uses defineAgent, and triage becomes a defineWorkflow default export with validated input and runtime config loading.
Tool contract migration
src/tools/*.ts
The query and monitoring tools switch their schema field from parameters to input and their handlers from execute to run, while keeping the existing downstream calls.
Kubectl and kubeconfig tools
src/tools/kubectl.ts, src/tools/kubeconfig.ts
The kubectl and kubeconfig tools switch to input/run, including the existing context, namespace, and locked-namespace handling.
MCP tool bridge
src/mcp-mode.ts
The MCP bridge reads tool.input, validates against tool.input, calls tool.run({ input: validatedArgs }), and formats string or JSON-stringified results for MCP responses.
Tool tests
src/tools/__tests__/*.test.ts
The tool tests move to run({ input: ... }) and keep the same forwarding, blocked-result, timeout, and precedence assertions.

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 }
Loading

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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • billzhuang/heimdall#13: Directly overlaps with the agent/runtime API shift that this PR extends to defineAgent and defineWorkflow.
  • billzhuang/heimdall#79: Touches the same tool-test surface that now calls run({ input: ... }) instead of execute(...).
  • billzhuang/heimdall#95: Introduces the tool-system contract changes that this PR applies across tool definitions and MCP execution.

Poem

A rabbit hopped through input fields so neat,
With run() in paw and carrots at his feet 🥕
The moon lit up the triage trail,
MCP sang soft, “Your tools won’t fail!”
And Flue went hop-happily complete.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main changes: Flue package upgrades to beta.6 and migration to the new tool API.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/zen-galileo-0kw1df

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist 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.

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.

Comment thread src/tools/kubeconfig.ts
Comment on lines +51 to 56
input: v.object({
context: v.pipe(
v.optional(v.string()),
v.description('Cluster context to query. Defaults to the configured/current context.'),
),
}),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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.

Suggested change
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
  1. 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.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

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

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 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".

Comment thread src/tools/kubectl.ts
),
}),
execute: async ({ args, context }) =>
run: async ({ input: { args, context } }) =>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

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

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/workflows/triage.ts (1)

12-13: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Stale HTTP-exposure example.

The header comment still shows the old export const route: WorkflowRouteHandler pattern. Confirm this still applies under the defineWorkflow default-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

📥 Commits

Reviewing files that changed from the base of the PR and between f90d708 and 10a5b65.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (27)
  • package.json
  • src/agents/heimdall.ts
  • src/mcp-mode.ts
  • src/tools/__tests__/aws.test.ts
  • src/tools/__tests__/cdk.test.ts
  • src/tools/__tests__/datadog.test.ts
  • src/tools/__tests__/helm.test.ts
  • src/tools/__tests__/jaeger.test.ts
  • src/tools/__tests__/kubecost.test.ts
  • src/tools/__tests__/loki.test.ts
  • src/tools/__tests__/newrelic.test.ts
  • src/tools/__tests__/prometheus.test.ts
  • src/tools/__tests__/tools.test.ts
  • src/tools/__tests__/trivy.test.ts
  • src/tools/aws.ts
  • src/tools/cdk.ts
  • src/tools/datadog.ts
  • src/tools/helm.ts
  • src/tools/jaeger.ts
  • src/tools/kubeconfig.ts
  • src/tools/kubecost.ts
  • src/tools/kubectl.ts
  • src/tools/loki.ts
  • src/tools/newrelic.ts
  • src/tools/prometheus.ts
  • src/tools/trivy.ts
  • src/workflows/triage.ts

Comment thread src/mcp-mode.ts Outdated
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
@billzhuang
billzhuang merged commit acda347 into main Jun 26, 2026
4 of 5 checks passed
@billzhuang
billzhuang deleted the claude/zen-galileo-0kw1df branch June 26, 2026 01:58
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