[Bug] Jinja2 variables used only inside {% if %} / {% for %} are missing from input_keys, so invoke returns 400
I maintainer di solito rispondono entro 1 giorno
@mmabrouk ci sta già lavorando.
Dal 19/10/2026.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 88/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- backend
Direzione di ricerca
Inizia da extractTemplateVariables in web/packages/agenta-entities/src/runnable/utils.ts e provala con il template Jinja2 fornito. Individua i test vicini di questa utilità e aggiungi la copertura per le variabili usate solo nei blocchi {% if %} e {% for %}, escludendo le variabili di loop e le dichiarazioni {% set %}. La modifica è completa quando gli input rilevati corrispondono alle variabili Jinja2 non dichiarate, così playground espone is_vip e tickets e invoke non rifiuta più questi input con un 400.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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:
- Playground: there is no field for the missing variables, so the template always takes the
{% else %}branch. - Invoke endpoint:
/services/chat/v0/invokevalidates inputs against the storedinput_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
- Create a chat app and set the prompt syntax to Jinja2.
- Paste the template above into the system message and
{{ customer_message }}into the user message. - Look at the variables panel: it lists
companyand an objectticket(id,title). There is nois_vipand notickets. - Run it in the playground: the reply follows the
{% else %}branches ("No open tickets"), even for a VIP customer with open tickets. - 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.
- Lingua principale
- TypeScript
- Stelle
- 4.8k
- Fork
- 690
- Merge medio
- 22h 44m
- PR unite (30g)
- 413
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Agenta-AI/agenta
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
Agenta-AI/agenta#7654 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
Agenta-AI/agenta#7468 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
(bug) The Stop button disappears for a moment before an approval card showsForse di nuovo libera @rishu685 l’ha presa 15 giorni fa e non c’è nessuna pull request aperta. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Agenta-AI/agenta#7446 · 2 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
Agenta-AI/agenta#7441 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
(bug) Settings > Usage opens AI providers when billing is offForse già presa @adityasingh345 l’ha presa 8 giorni fa. Apertabug frontend
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
Agenta-AI/agenta#7426 · 2 commenti · 2 reazioni ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Agenta-AI/agenta
Issue simili
-
level/task type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
wazuh/wazuh-dashboard-plugins#9508 ·
I maintainer di solito rispondono entro 1 giorno
-
Testnet EOL page links Zonescan mainnetForse già presa @napelvs l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 76/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Azure-Samples/azure-search-openai-demo#3249 ·
I maintainer di solito rispondono entro 1 giorno
-
[Docs] docs/architecture.mermaid leaves out 21 of the 51 src/ directoriesForse già presa @uyg7x l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement status:needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
dongdongbh/Mindwtr#1438 ·
I maintainer di solito rispondono entro 1 giorno