Skip to content

Proposal: Task Output Caching#173

Merged
thalesraymond merged 1 commit intomainfrom
feat-task-caching-proposal-14087489645052090480
Feb 25, 2026
Merged

Proposal: Task Output Caching#173
thalesraymond merged 1 commit intomainfrom
feat-task-caching-proposal-14087489645052090480

Conversation

@thalesraymond
Copy link
Owner

Proposed a new "Task Output Caching" feature using the OpenSpec workflow.

  • Created openspec/changes/feat-task-caching/ directory.
  • Added proposal.md detailing the need for caching to avoid redundant execution.
  • Added tasks.md with a breakdown of implementation steps (Interfaces, Strategy, Tests).
  • Added design.md covering architectural decisions (e.g., pluggable providers, restore callback).
  • Added specs/task-runner/spec.md with formal requirements for TaskCacheConfig, CachingExecutionStrategy, and ICacheProvider.
  • Verified files against OpenSpec guidelines and ran project checks (build, lint, test).

PR created automatically by Jules for task 14087489645052090480 started by @thalesraymond

This commit adds a new OpenSpec proposal for Task Output Caching.
It includes:
- `proposal.md`: Rationale and scope.
- `tasks.md`: Implementation checklist.
- `design.md`: Architectural decisions and trade-offs.
- `specs/task-runner/spec.md`: Delta requirements for `TaskStep` and execution strategy.

This feature will allow tasks to skip execution if their inputs haven't changed, significantly improving performance for repeated workflows.

Co-authored-by: thalesraymond <32554150+thalesraymond@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @thalesraymond, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a comprehensive proposal for a new "Task Output Caching" feature within the task runner. The core objective is to significantly enhance performance by preventing the redundant execution of computationally expensive tasks when their inputs or context remain unchanged. The proposal outlines the necessary modifications to task configuration, introduces a dedicated caching execution strategy, and establishes a pluggable caching mechanism to support various backend implementations, ensuring efficient and flexible task processing.

Highlights

  • Task Configuration Enhancement: The TaskStep interface has been extended to include an optional cache property. This allows tasks to define a unique cache key, an optional time-to-live (TTL), and a restore callback function to re-apply context side effects from cached results.
  • New Caching Execution Strategy: A CachingExecutionStrategy is introduced, designed to wrap existing execution strategies. It intelligently checks for cached results before executing a task, skipping redundant work on cache hits and storing successful task outcomes for future use.
  • Pluggable Caching Mechanism: An ICacheProvider interface has been defined to support various caching backends, promoting extensibility. A default MemoryCacheProvider is included for in-memory caching, with provisions for future file system or remote cache implementations.
  • Architectural Design and Risks: Detailed architectural decisions emphasize the use of ICacheProvider for flexibility, an explicit restore callback for correct context handling, and wrapping execution strategies for separation of concerns. Potential risks like stale cache data and context inconsistency are identified with proposed mitigations.
Changelog
  • openspec/changes/feat-task-caching/design.md
    • Added a new document detailing the architectural decisions for the task output caching feature.
    • Outlined the goals, non-goals, specific design choices (e.g., ICacheProvider, restore callback), potential risks, and a migration plan for the caching implementation.
  • openspec/changes/feat-task-caching/proposal.md
    • Added a new proposal document explaining the motivation and high-level changes for implementing task output caching.
    • Described the problem of redundant execution and how the proposed changes to task configuration, execution strategy, and cache provider will address it, along with the expected performance impact.
  • openspec/changes/feat-task-caching/specs/task-runner/spec.md
    • Added new formal requirements for the task caching feature within the task-runner specification.
    • Defined detailed requirements for TaskCacheConfig, the behavior of CachingExecutionStrategy (including cache hit, miss, and expiration scenarios), the ICacheProvider interface methods, and the default MemoryCacheProvider.
  • openspec/changes/feat-task-caching/tasks.md
    • Added a new document outlining the detailed implementation steps required to develop the task output caching feature.
    • Listed specific tasks such as defining interfaces, implementing providers, updating existing interfaces, creating the caching strategy, and adding comprehensive unit and integration tests.
Activity
  • The pull request was automatically created by Jules for a task initiated by @thalesraymond.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@sonarqubecloud
Copy link

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

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 introduces a proposal for a new task output caching feature. The design is well-structured and thoughtful, particularly with the inclusion of a pluggable ICacheProvider and a restore callback to handle side effects. My review focuses on refining the specification to address potential edge cases and ambiguities. I've suggested clarifications around failure handling for the restore function, the status of cached tasks, handling of non-serializable data, and ensuring consistency across the proposal documents. Addressing these points will help create a more robust and predictable feature.


- **WHEN** the `CachingExecutionStrategy` executes a task with a cache key that IS present in the cache provider
- **THEN** it SHALL NOT execute the inner strategy.
- **AND** it SHALL invoke the `restore` function (if provided) with the current context and the cached result.
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The specification doesn't cover what happens if the restore function fails (e.g., throws an error). This is a critical edge case that could lead to an inconsistent application state. The task should be marked as failed in this scenario. Please add a requirement to handle this.

- **Task Configuration**: Add `cache` configuration to `TaskStep` interface, allowing tasks to define a cache key and a restoration logic.
- **Execution Strategy**: Introduce `CachingExecutionStrategy` that wraps other strategies. It checks for a cached result before execution and stores the result after successful execution.
- **Cache Provider**: Define an `ICacheProvider` interface with a default in-memory implementation (`MemoryCacheProvider`), allowing for future extension (e.g., file system or remote cache).
- **Task Result**: Ensure `TaskResult` is serializable and contains necessary metadata for caching.
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This point is crucial, but lacks detail on enforcement. The TaskResult.data property is of type unknown, which allows for non-serializable values. The proposal should specify how the system will handle non-serializable data in a cached task's result. Will it cause a runtime error during the caching process, or should there be a mechanism to prevent this, for example by using a more specific type for data on cacheable tasks?

- **WHEN** the `CachingExecutionStrategy` executes a task with a cache key that IS present in the cache provider
- **THEN** it SHALL NOT execute the inner strategy.
- **AND** it SHALL invoke the `restore` function (if provided) with the current context and the cached result.
- **AND** it SHALL return the cached result.
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Returning the original cached result might be confusing, as its status (e.g., success) doesn't reflect that the task was restored from cache, not executed. It would be more informative to return a result with a new status, like cached, as hinted at in tasks.md. This would improve observability of the workflow execution.

Suggested change
- **AND** it SHALL return the cached result.
- **AND** it SHALL return a `TaskResult` with a status of `cached`.

- Calculate cache key using `step.cache.key(context)`.
- Check cache provider. If hit:
- Execute `step.cache.restore(context, result)` if provided.
- Return cached result with status `skipped` (or a new status `cached`).
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This is a great implementation detail, but it introduces a potential ambiguity. It's not clear if 'Return cached result with status...' means modifying the cached object or creating a new one. Modifying cached data is risky. It would be better to specify that a new TaskResult should be created. Also, this requirement is important enough to be in specs/task-runner/spec.md to ensure it's part of the formal contract.

@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@thalesraymond thalesraymond merged commit 97f524a into main Feb 25, 2026
7 checks passed
@thalesraymond thalesraymond deleted the feat-task-caching-proposal-14087489645052090480 branch February 25, 2026 22: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.

1 participant