Skip to content

[BUG] Context variable references in agent prompts cause errors #1382

@dobesv

Description

@dobesv

📋 Prerequisites

  • I have searched the existing issues to avoid creating a duplicate
  • By submitting this issue, you agree to follow our Code of Conduct
  • I am using the latest version of the software
  • I have tried to clear cache/cookies or used incognito mode (if ui-related)
  • I can consistently reproduce this issue

🎯 Affected Service(s)

App Service

🚦 Impact/Severity

Minor inconvenience

🐛 Bug Description

If you write some text like {repo} in your agent prompt you can get an error like:

2026-02-25 19:56:39,014 - kagent_adk.kagent.adk._agent_executor - ERROR - Error handling A2A request: 'Context variable not found: repo.'
  File "/.kagent/.venv/lib/python3.13/site-packages/google/adk/utils/instructions_utils.py", line 131, in _replace_match
    raise KeyError(f'Context variable not found: {var_name}.')
KeyError: 'Context variable not found: repo.'

I don't think there's any practical way to set these context variables in kagent, so this ADK feature should probably be disabled or the {}'s should be automatically escaped.

🔄 Steps To Reproduce

  1. Create an agent with a prompt with {repo} or similar in it
  2. Try to use it

🤔 Expected Behavior

Does not try to process {...}

📱 Actual Behavior

Error

💻 Environment

No response

🔧 CLI Bug Report

No response

🔍 Additional Context

No response

📋 Logs

📷 Screenshots

No response

🙋 Are you willing to contribute?

  • I am willing to submit a PR to fix this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions