Fix: Escape JSON braces in LangChain prompt template - #636
Conversation
- Add PYTHONPATH to analyze and dedup steps for tools module import - Fix long lines that exceed 100 characters
LangChain interprets single braces {} as template variables.
The JSON example in the prompt must use double braces {{}} to
escape them and prevent KeyError during prompt formatting.
Fixes workflow error: KeyError: Input to ChatPromptTemplate is
missing variables {task_splitting}
Automated Status SummaryHead SHA: fcb64e6
Coverage Overview
Coverage Trend
Top Coverage Hotspots (lowest coverage)
Updated automatically; will refresh on subsequent CI/Docker completions. Keepalive checklistScopeNo scope information available Tasks
Acceptance criteria
|
🤖 Keepalive Loop StatusPR #636 | Agent: Codex | Iteration 0/5 Current State
🔍 Failure Classification| Error type | infrastructure | |
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical bug in the agents:optimize workflow where LangChain was interpreting JSON example braces in the prompt template as template variables, causing a KeyError. The fix properly escapes JSON braces with double braces ({{}}) in the prompt template so they are treated as literal characters.
Key Changes:
- Escape JSON braces in
analyze_issue.mdprompt template to prevent LangChain variable interpretation - Add PYTHONPATH environment variable to workflow steps for proper Python module resolution
- Improve workflow script formatting (multi-line commands, split echo statements)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
scripts/langchain/prompts/analyze_issue.md |
Escape all JSON braces in the output format example with double braces to prevent LangChain from treating them as template variables |
templates/consumer-repo/.github/workflows/agents-issue-optimizer.yml |
Add PYTHONPATH environment variable, improve command formatting, and update quoting (contains errors in escaped quotes) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| GH_TOKEN: ${{ github.token }} | ||
| run: | | ||
| echo "Extracting suggestions from comments on issue #${ISSUE_NUMBER}" | ||
| echo \"Extracting suggestions from comments on issue #${ISSUE_NUMBER}\" |
There was a problem hiding this comment.
The backslash-escaped quotes around the echo statement are incorrect for YAML. In GitHub Actions workflow files, strings in the run block don't need backslash escaping. The backslashes will be interpreted literally, causing the command to fail.
Remove the backslashes and use plain double quotes or no quotes at all for the echo statement.
| echo \"Extracting suggestions from comments on issue #${ISSUE_NUMBER}\" | |
| echo "Extracting suggestions from comments on issue #${ISSUE_NUMBER}" |
| gh api \ | ||
| \"repos/${{ github.repository }}/issues/${ISSUE_NUMBER}/comments\" \ | ||
| --paginate > /tmp/comments.json |
There was a problem hiding this comment.
The backslash-escaped quotes around the gh api command are incorrect for YAML. In GitHub Actions workflow files, strings in the run block don't need backslash escaping. The backslashes will be interpreted literally by the shell, causing a syntax error.
Remove the backslashes and use plain double quotes or no quotes at all.
Automated Status Summary
Scope
Address unmet acceptance criteria from PR #183.
Original scope:
Context for Agent
Related Issues/PRs
References
Tasks
Acceptance criteria
Head SHA: 37acb59
Latest Runs: ✅ success — Gate
Required: gate: ✅ success