[BUG] Flow.input_history is referenced by two docstrings but does not exist

オープン
#9,216 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@lxcxjxhx がすでに取り組んでいます。

2026年11月7日 から。

  • #9218 @lxcxjxhx による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python
領域
backend

調査の方向性

Start in crewai/flow/runtime/__init__.py, where the issue says _input_history is defined, and read the references in crewai/flow/conversation.py and crewai/flow/input_provider.py. Check the existing flow tests for history behavior, then verify that callers can inspect the prompt, response, and metadata through the documented API. A linked open pull request (#9218) is already addressing this issue.

索引モデルが issue の本文から書いたものです。

説明

Flow.input_history is referenced by two module docstrings but does not exist

What

crewai/flow/conversation.py:232 documents its input as "Convert Flow.input_history entries to LLM message format", and crewai/flow/input_provider.py:68 explains that "The response metadata is stored in _input_history". But Flow exposes no public input_history; the history exists only as a private pydantic attribute.

On crewai==1.15.37, installed from this repository's lib/crewai:

>>> from crewai.flow import Flow
>>> hasattr(Flow, "input_history")
False
>>> "_input_history" in Flow.__private_attributes__
True

So the only way to read what Flow.ask() asked and what came back — the request message, the response, the request metadata and the provider's InputResponse.metadata — is the private attribute.

Why it matters

This is the accessor that makes InputProvider/InputResponse usable: without it, a custom provider can carry response metadata but nothing documented can read it back. It also blocks the docs task in #8071, whose acceptance criteria say "show how to inspect response metadata using the existing flow.input_history API" — that criterion cannot be satisfied today.

Reproduction (scripted provider, no console, no LLM):

from crewai.flow import Flow, start
from crewai.flow.input_provider import InputResponse


class ScriptedProvider:
    def request_input(self, message, flow, metadata=None):
        return InputResponse(text="vector databases", metadata={"answered_by": "script"})


class ResearchFlow(Flow):
    input_provider = ScriptedProvider()

    @start()
    def gather(self):
        return self.ask("What should we research?", metadata={"channel": "#research"})


flow = ResearchFlow()
print(flow.kickoff())              # vector databases
print(flow._input_history)         # the metadata only exists here
print(hasattr(flow, "input_history"))  # False

Suggested fix (small, no behaviour change)

@property
def input_history(self) -> list[InputHistoryEntry]:
    """Return the ``Flow.ask()`` requests this flow has served.

    Each entry carries the prompt, the response (``None`` when the provider had
    nothing to give), the method that asked, the timestamp, the request metadata and
    the provider's ``InputResponse.metadata``.

    Returns:
        list[InputHistoryEntry]: A copy, so callers cannot mutate the flow's history.
    """
    return list(self._input_history)

InputHistoryEntry is already imported at the top of crewai/flow/runtime/__init__.py (line 128) for the private attribute's annotation, so this needs no new imports. Returning a copy keeps the existing append-only contract.

Note

I raised this in #8071 before writing the guide section, because the example the issue asks for would otherwise have to teach the private attribute. Happy to send the property + a unit test as the PR for this issue if you want it; the docs example then follows in #8071.

主要言語
Python
スター
60.6k
フォーク
9.1k
平均マージ
1日 2時間
マージ済み PR(30日)
214

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

crewAIInc/crewAI のほかの issue

crewAIInc/crewAI の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。