Skip to content

Feature: Auto GitHub comment middleware for models that skip github_comment tool #1118

@argenisleon

Description

Description

Some LLM models (e.g., MiniMax M2.7) don't reliably call the github_comment tool at the end of their run, leaving GitHub issues/PRs without a response even though the agent successfully completed the task.

Problem

When using non-Anthropic models, the agent may:

  1. Successfully process the request
  2. Generate a valid response
  3. But never call github_comment to post the result back

The user sees no response on GitHub even though the agent worked correctly.

Proposed Solution

An @after_agent middleware that acts as a safety net:

  1. Checks if the source is "github"
  2. Checks if the agent already called github_comment (if so, does nothing)
  3. Collects all AI text messages from the current run (since last human message)
  4. Strips <think> blocks (used by some models for chain-of-thought)
  5. Posts the collected text as a GitHub comment

This is a no-op when the model correctly calls github_comment on its own, so it's safe to include in the middleware chain for all models.

Key design decisions:

  • Scoped to current run only (_messages_since_last_human) to avoid reposting from previous runs
  • No filtering of message types — all AI text is included
  • Strips <think>...</think> reasoning blocks that some models embed

I have a PR ready with the implementation and 24 tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions