Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[Bug] Jinja2 variables used only inside {% if %} / {% for %} are missing from input_keys, so invoke returns 400

オープン 初心者向け
#7,669 コメント 3 件 リアクション 1 件 担当者 1 名 GitHub で見る

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

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

2026年10月19日 から。

  • #7718 @TPSJASPER による — マージされずにクローズ
  • #7719 @TPSJASPER による — オープン

評価

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

調査の方向性

まず web/packages/agenta-entities/src/runnable/utils.ts の extractTemplateVariables から始め、提供された Jinja2 テンプレートに対してテストします。このユーティリティ付近のテストを見つけ、{% if %} と {% for %} ブロック内でのみ使用される変数のカバレッジを追加します。ループターゲットと {% set %} のバインディングは除外します。完了条件は、検出された入力が Jinja2 の未宣言変数と一致し、playground が is_vip と tickets を公開し、invoke がこれらの入力を 400 で拒否しなくなることです。

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

説明

bug frontend
Describe the bug

With the prompt syntax set to Jinja2, the playground's variable detection skips every {% ... %} block. A variable that appears only inside {% if %} or {% for %} gets no input field and is left out of the stored input_keys. The loop variable that the template defines itself is listed as an input instead.

Two effects follow:

  1. Playground: there is no field for the missing variables, so the template always takes the {% else %} branch.
  2. Invoke endpoint: /services/chat/v0/invoke validates inputs against the stored input_keys, so a request that sends the real variables is rejected with a 400.

Template used (system message, template_format: jinja2):

You are a support triage agent for {{ company }}.
{% if is_vip %}This customer is VIP — prioritize them and skip standard hold times.{% else %}Standard support flow applies.{% endif %}
{% if tickets %}Open tickets:
{% for ticket in tickets %}- #{{ ticket.id }}: {{ ticket.title }}
{% endfor %}{% else %}No open tickets.{% endif %}

The template reads company, is_vip and tickets (plus customer_message in the user message). The stored revision has:

"input_keys": ["company", "ticket", "customer_message"]

is_vip and tickets are missing, and ticket (the loop variable) is present.

Setup

Self-hosted OSS, version 0.122.7, Docker Compose on Linux. Model openrouter/openai/gpt-4o-mini.

To Reproduce
  1. Create a chat app and set the prompt syntax to Jinja2.
  2. Paste the template above into the system message and {{ customer_message }} into the user message.
  3. Look at the variables panel: it lists company and an object ticket (id, title). There is no is_vip and no tickets.
  4. Run it in the playground: the reply follows the {% else %} branches ("No open tickets"), even for a VIP customer with open tickets.
  5. Commit, then call invoke with the variables the template really uses:
curl -X POST http://localhost/services/chat/v0/invoke \
  -H "Authorization: ApiKey $AGENTA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"data":{"inputs":{"company":"Acme","is_vip":true,"tickets":[{"id":4821,"title":"Refund not received"}],"customer_message":"Where is my refund?"}},
       "references":{"application_revision":{"id":"<revision id>"}}}'

Response (HTTP 400):

{"version":"2025.07.14","status":{"code":400,"message":"Invalid inputs:\nExpected '['company', 'customer_message', 'ticket']'\nGot ('list') '['company', 'customer_message', 'is_vip', 'tickets']'.","type":"https://agenta.ai/docs/misc/errors#v0:schemas:invalid-inputs"}}

Workaround: edit input_keys by hand in the JSON view to ["company", "is_vip", "tickets", "customer_message"] and commit a new revision. After that, the same invoke call succeeds and the VIP branch renders.

Expected behavior

For Jinja2, the input list should contain every name the template reads, including names used only in {% if %} / {% for %} conditions (is_vip, tickets). Names the template binds itself (the for loop target ticket, {% set %} names) should not be inputs. Jinja2's own jinja2.meta.find_undeclared_variables returns exactly {'company', 'is_vip', 'tickets'} for this template.

Likely cause

extractTemplateVariables scans only {{ ... }} for jinja2, and its doc comment says blocks {% %} are ignored. Mustache already tracks sections in the same function ({{#name}} emits name); Jinja2 has no equivalent, so {% if is_vip %} and {% for ticket in tickets %} emit nothing, while {{ ticket.id }} emits ticket.

主要言語
TypeScript
スター
4.8k
フォーク
690
平均マージ
1日 2時間
マージ済み PR(30日)
431

環境構築

はじめの一歩

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

Agenta-AI/agenta のほかの issue

Agenta-AI/agenta の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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