Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Groq leadding too issue with response model. #2044

Open
alaap001 opened this issue Feb 7, 2025 · 3 comments
Open

[Bug] Groq leadding too issue with response model. #2044

alaap001 opened this issue Feb 7, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@alaap001
Copy link

alaap001 commented Feb 7, 2025

Description

When using Groq model with response model I get following error:

ERROR    Workflow.run() failed: Error code: 400 - {'error': {'message': "'messages' must contain the word 'json' in some form, to use 'response_format' of type 'json_object'.", 'type': 'invalid_request_error'}}

With a different config of agent I also get below:

ERROR    Workflow.run() failed: Error code: 400 - {'error': {'message': "'messages.1' : discriminator property 'role' has invalid value", 'type': 'invalid_request_error'}}

Agen defiinition

return Agent(
        name="Intent Recognizer",
        add_history_to_messages=True,
        add_datetime_to_instructions=True,
        storage=SqliteAgentStorage(table_name="agent_sessions", db_file="tmp/agent_sessions.db"),
        add_references=False,
        knowledge=intent_knowledge_base,
        search_knowledge=True,
        debug_mode=True,
        model=Groq(id="llama-3.3-70b-versatile"),
        response_model=IntentRecog,
        structured_outputs=True,
    )

Agent Configuration 2

return Agent(
        name="Assiistant
        description="",
        system_message=dedent("""\
            You are a highly skilled Assiistant\
            """),
        instructions=[
               "help me",
        ],
        storage=SqliteAgentStorage(table_name="agent_sessions", db_file="tmp/agent_sessions.db"),
        knowledge=assistant_knowledge_base,
        add_history_to_messages=True,
        add_references=True,
        search_knowledge=False,
        debug_mode=True,
        model=Groq(id="deepseek-r1-distill-llama-70b", temperature=0.1),
    )

Expected Behavior

Other models are working fine, even if I run same model locally. but in groq it's not worrking.

Environment

  • OS: Ubuntu
  • Agno Version: v1.0.6
@alaap001 alaap001 added the bug Something isn't working label Feb 7, 2025
@dhana-rajeswari
Copy link

import json
messages = [
{"role": "system", "content": "You are an assistant."},
{"role": "human", "content": "Hello, what can you do?"}, # INVALID role!
{"role": "assistant", "content": "I can help answer questions!"}
]
VALID_ROLES = {"system", "user", "assistant"}
def validate_messages(messages):
fixed_messages = []
for message in messages:
if "role" not in message or "content" not in message:
print(f"⚠️ Skipping malformed message: {message}")
continue

    if message["role"] not in VALID_ROLES:
        print(f"⚠️ Invalid role '{message['role']}' found. Replacing with 'user'.")
        message["role"] = "user"  # Default fallback role
      fixed_messages.append(message)
          return fixed_messages
     messages = validate_messages(messages)
     print("✅ Final Messages Before Sending:")
     print(json.dumps(messages, indent=2))

try:
agent = Agent(
name="Intent Recognizer",
add_history_to_messages=True,
add_datetime_to_instructions=True,
storage=SqliteAgentStorage(table_name="agent_sessions", db_file="tmp/agent_sessions.db"),
add_references=False,
knowledge=intent_knowledge_base,
search_knowledge=True,
debug_mode=True,
model=Groq(id="llama-3.3-70b-versatile"),
response_model=IntentRecog,
structured_outputs=True,
)

result = agent.run(messages=messages)
print("✅ Workflow executed successfully:", result)

except Exception as e:
print("❌ ERROR: Workflow.run() failed:", str(e))

@dirkbrnd
Copy link
Contributor

@alaap001 Have you managed to resolve this? It looks like you are using manually defined roles in messages?
If it is still an issue, please provide your full code so we can take a look.

@dirkbrnd
Copy link
Contributor

@alaap001

  1. Groq doesn't actually allow tool calling and structured output at the same time. When you add a knowledge base and search_knowledge, then that adds tools for the agent. I am making a fix so this error is more apparent.
  2. On your second agent I could not replicate any issue. It is working fine for me. Are you on the latest version of agno?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants