Skip to content

action optimizations#1

Merged
derekmisler merged 7 commits intodocker:mainfrom
derekmisler:action-optimizations
Oct 30, 2025
Merged

action optimizations#1
derekmisler merged 7 commits intodocker:mainfrom
derekmisler:action-optimizations

Conversation

@derekmisler
Copy link
Copy Markdown
Contributor

@derekmisler derekmisler commented Oct 29, 2025

This PR significantly enhances the cagent-action with improvements to reliability, performance, and user experience while maintaining full backward compatibility.

🎯 Summary

  • Performance: Binary caching reduces typical run time by 10-30 seconds
  • Reliability: Retry logic handles transient network failures gracefully
  • Visibility: Job summaries and new outputs make results easily accessible
  • Control: Timeout prevents runaway agents from consuming resources
  • Debugging: Debug mode helps diagnose issues quickly

✨ New Features

Binary Caching

  • Caches cagent and mcp-gateway binaries using actions/cache
  • Cache keys based on OS and version (e.g., cagent-Linux-v1.6.6)
  • Dramatically reduces execution time on repeated workflow runs

Retry Logic & Verification

  • Downloads retry up to 3 times on failure with 2-second delays
  • Binary verification ensures downloads aren't corrupted
  • Clear error messages if all retry attempts fail

Timeout Control

- uses: docker/cagent-action@v1
  with:
    agent: jeanlaurent/pr-reviewer
    timeout: 600  # 10 minute timeout

Debug Mode

- uses: docker/cagent-action@v1
  with:
    agent: jeanlaurent/pr-reviewer
    debug: true  # Enables verbose logging

GitHub Actions Job Summary

Automatically creates a formatted summary in the Actions UI:

  • Agent execution details in a markdown table
  • Visual status indicators (✅ success, ❌ failed, ⏱️ timeout)
  • Expandable section with last 100 lines of output

New Outputs

- id: agent-run
  uses: docker/cagent-action@v1

- run: |
    echo "Took ${{ steps.agent-run.outputs.execution-time }}s"
    echo "Version: ${{ steps.agent-run.outputs.cagent-version }}"
    echo "MCP: ${{ steps.agent-run.outputs.mcp-gateway-installed }}"

🐛 Fixes

  • Fixed: Missing github-token input definition (was referenced but not defined)
  • Fixed: MCP Gateway installation logic now correctly uses mcp-gateway boolean
  • Improved: Version validation provides clear error messages before attempting downloads

📝 New Inputs

Input Description Default
github-token GitHub token for API access ${{ github.token }}
timeout Timeout in seconds (0 = no timeout) 0
debug Enable verbose logging false

📊 New Outputs

Output Description
output-file Path to the output log file (was missing from docs)
cagent-version Version of cagent that was used
mcp-gateway-installed Whether mcp-gateway was installed
execution-time Agent execution time in seconds

🔄 Breaking Changes

None! All changes are backward compatible. Existing workflows will continue to work without modification.

📚 Documentation

  • Updated README with all new inputs and outputs
  • Added examples showing how to use new features
  • Added "Using Outputs" section demonstrating practical use cases

🧪 Testing

Tested with existing test workflows:

  • ✅ Successful agent execution
  • ✅ Invalid agent failure handling
  • ✅ Binary caching behavior
  • ✅ Timeout functionality
  • ✅ Job summary generation

@derekmisler derekmisler self-assigned this Oct 29, 2025
@github-advanced-security
Copy link
Copy Markdown

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

Fixes undefined reference to inputs.github-token in action.yml:92.
The token defaults to the automatically provided github.token context variable.
- Add timeout input to limit agent execution time (default: 0 = no timeout)
- Add debug input to enable verbose logging throughout the action
- These inputs will be used in subsequent commits to add timeout handling
  and debug output to binary setup and agent execution steps
Add three new outputs to provide better visibility into action execution:
- cagent-version: The version of cagent that was used
- mcp-gateway-installed: Whether mcp-gateway was installed (true/false)
- execution-time: Agent execution time in seconds

These outputs enable conditional workflow logic based on execution results
and help users track performance and configuration of their agent runs.
Validates version format before attempting downloads to provide clearer
error messages. Versions must match the pattern v1.2.3 (with optional
suffixes like -rc1).

Also adds debug logging when debug mode is enabled, showing the versions
that will be downloaded.
@derekmisler
Copy link
Copy Markdown
Contributor Author

Example output:

Screenshot 2025-10-29 at 7 15 42 PM

@derekmisler derekmisler marked this pull request as ready for review October 29, 2025 23:49
@derekmisler derekmisler requested review from a team, Copilot and jeanlaurent October 29, 2025 23:49
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the cagent-action with performance optimizations, reliability improvements, and better observability while maintaining backward compatibility. The changes introduce binary caching to reduce execution time, retry logic for network failures, configurable timeouts, debug mode, and automated job summaries.

Key changes:

  • Binary caching using GitHub Actions cache to avoid repeated downloads
  • Retry logic with verification for binary downloads
  • New inputs for timeout control, debug mode, and explicit github-token parameter
  • New outputs for execution metrics (execution-time, cagent-version, mcp-gateway-installed)
  • Automated job summary generation with formatted execution details

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
action.yml Adds version validation, binary caching, retry logic, timeout support, debug mode, and job summary generation; defines new inputs (github-token, timeout, debug) and outputs (cagent-version, mcp-gateway-installed, execution-time)
README.md Documents new inputs (timeout, debug), outputs (output-file, cagent-version, mcp-gateway-installed, execution-time), and adds usage examples

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@docker docker deleted a comment from Copilot AI Oct 29, 2025
Major improvements to binary download reliability and performance:

- Add GitHub Actions cache for both cagent and mcp-gateway binaries
  - Cache keys based on OS and version
  - Significantly reduces execution time on repeated runs

- Implement retry_download function with 3 attempts
  - Uses curl's built-in retry with delays
  - Manual retry loop with 2-second delays between attempts
  - Clear error messages if all attempts fail

- Add binary verification after download
  - Runs 'version' command to ensure binary works
  - Exits with error if verification fails

- Consolidate binary setup into single step (setup-binaries)
  - Sets outputs for cagent-version and mcp-installed
  - Respects debug mode for verbose logging

- Fix mcp-gateway installation conditional
  - Now only installs when mcp-gateway input is 'true'
@derekmisler derekmisler requested a review from Copilot October 29, 2025 23:58
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Enhance the Run CAgent step with:

Timeout Support:
- Implement timeout using bash 'timeout' command
- Exit code 124 indicates timeout occurred
- Clear error message when timeout is reached

Execution Time Tracking:
- Track start and end time of agent execution
- Output execution-time in seconds for use in subsequent steps

GitHub Actions Job Summary:
- Create formatted markdown summary table
- Show agent name, exit code, execution time, versions
- Visual status indicators (✅ success, ❌ failed, ⏱️ timeout)
- Expandable section with last 100 lines of agent output
- Summary appears in GitHub Actions UI for easy review

Debug Mode Support:
- Enable bash tracing (set -x) when debug mode is on
- Output working directory and workspace paths
- Log exit code, execution time, and output file location
Documentation updates:

New Inputs:
- timeout: Timeout in seconds for agent execution
- debug: Enable debug mode with verbose logging
- github-token: Now properly documented with default value

New Outputs:
- output-file: Path to the output log file (was missing)
- cagent-version: Version of cagent that was used
- mcp-gateway-installed: Whether mcp-gateway was installed
- execution-time: Agent execution time in seconds

New Examples:
- Updated Advanced Configuration to show timeout and debug inputs
- Added 'Using Outputs' section demonstrating:
  - How to access action outputs in subsequent steps
  - Conditional logic based on execution time
  - Uploading output log as artifact

All examples updated to reflect new capabilities while maintaining
backward compatibility with existing workflows.
@derekmisler derekmisler merged commit 53d47e6 into docker:main Oct 30, 2025
3 checks passed
@derekmisler derekmisler added the kind/feature New feature or request label Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants