Skip to content

Conversation

hiroTamada
Copy link
Contributor

@hiroTamada hiroTamada commented Sep 26, 2025

Summary

This PR introduces two new features to enhance invocation management and debugging capabilities in the Kernel CLI:

  1. Invocation History Command (kernel invoke history) - View historical invocations across all apps or filtered by a specific app
  2. Per-Invocation Log Streaming (kernel logs <app> --invocation <id>) - Stream logs for a specific invocation run

Changes

New kernel invoke history Command

  • Lists all invocations across all apps by default
  • Supports filtering by app name using --app flag
  • Configurable result limit with --limit flag (default: 100)
  • Displays invocation details in a formatted table including:
    • Invocation ID
    • App Name
    • Action Name
    • Status (succeeded/failed/running)
    • Start time (local timezone)
    • Duration (with special handling for running invocations)
    • Output (truncated to 50 characters)

Usage:

# Show all invocations
kernel invoke history

# Show invocations for a specific app
kernel invoke history --app my-app

# Limit results
kernel invoke history --limit 20

Enhanced Log Streaming

  • Added --invocation flag to kernel logs command
  • Allows streaming logs for a specific invocation by ID or unambiguous prefix
  • Validates that the invocation belongs to the specified app
  • Respects --follow flag for continuous streaming
  • Implements a 3-second timeout for non-follow mode

Usage:

# Stream logs for a specific invocation
kernel logs my-app --invocation abc123

# Follow logs for a running invocation
kernel logs my-app --invocation abc123 --follow

Other Improvements

  • Added invocation ID logging when creating new invocations for easier reference
  • Updated SDK to v0.11.4
  • Fixed SDK API call signatures for FollowStreaming method
  • Improved error handling for streaming events

Technical Details

  • Simplified invocation history implementation to use a single API call instead of iterating through apps
  • Switched from ListAutoPaging to List to avoid pagination parsing issues
  • Added proper validation for command arguments in the invoke command

Testing

  • Tested invocation history with and without app filtering
  • Verified per-invocation log streaming for both running and completed invocations
  • Confirmed proper error handling and validation

TL;DR

Adds kernel invoke history to view past invocations and enhances kernel logs with an --invocation flag to stream logs for a specific run.

Why we made these changes

To improve debugging and observability by allowing users to easily find and view logs for specific invocation runs, instead of searching through an entire app's log stream.

What changed?

  • cmd/invoke.go:
    • Introduced the invoke history subcommand to list and filter recent invocations.
    • The invoke command now prints the invocation ID upon submission for easier reference.
  • cmd/logs.go:
    • Added an --invocation (-i) flag to stream logs for a specific invocation ID.
    • Enhanced log streaming to parse and display distinct error events.
  • go.mod & go.sum:
    • Bumped the kernel-go-sdk dependency from v0.11.1 to v0.11.4.

Description generated by Mesa. Update settings

@hiroTamada hiroTamada force-pushed the hiro/per_invocation_logging branch from 8a28557 to f656eb1 Compare September 26, 2025 02:37
Copy link

@mesa-dot-dev mesa-dot-dev bot left a comment

Choose a reason for hiding this comment

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

Performed full review of ff52a92...f656eb1

Analysis

  1. The PR switches from ListAutoPaging to List for API calls, which may create limitations when dealing with large datasets since pagination handling has been removed.

  2. The implementation introduces a new package pkg/util for time formatting, which could create additional dependencies and coupling if not carefully managed.

  3. The nested command structure using cobra, while following CLI patterns, may increase complexity and learning curve for users interacting with the CLI.

  4. The timeout management for non-follow mode may need careful review to ensure proper resource cleanup and avoid potential hanging processes.

Tip

⚡ Quick Actions

This review was generated by Mesa.

Actions:

Slash Commands:

  • /review - Request a full code review
  • /review latest - Review only changes since the last review
  • /describe - Generate PR description. This will update the PR body or issue comment depending on your configuration
  • /help - Get help with Mesa commands and configuration options

4 files reviewed | 0 comments | Review on Mesa | Edit Reviewer Settings

Copy link
Contributor

@masnwilliams masnwilliams left a comment

Choose a reason for hiding this comment

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

looking pretty solid to me

return nil
}

table := pterm.TableData{{"Invocation ID", "App Name", "Action", "Status", "Started At", "Duration", "Output"}}
Copy link
Contributor

Choose a reason for hiding this comment

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

app version also useful

Copy link
Contributor

Choose a reason for hiding this comment

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

in fact maybe even worth having the capability to filter on it in the API endpoint

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.

4 participants