Skip to content

Conversation

vesteny77
Copy link

@vesteny77 vesteny77 commented Jun 5, 2025

Description

This PR fixes the incorrect access of attribute reasoning_model in Configuration class.

Problem

In backend/src/agent/graph.py line 156(reflection) and line 234(finalize_answer),

reasoning_model = state.get("reasoning_model") or configurable.reasoning_model

raise the following error:

AttributeError: 'Configuration' object has no attribute 'reasoning_model'

Solution

In the reflection function, change reasoning_model to reflection_model;
in the finalize_answer function, change reasoning_model to answer_model.

Changes

graph.py line 156 and line 234

Impact

  • Fix runtime error when calling the reflection module and producing final output

Test

Place the following Python script in backend/src to test:

import sys
from dotenv import load_dotenv
from langchain_core.messages import BaseMessage, AIMessage
from agent.graph import graph

def main():
    load_dotenv()

    user_query = "What is Internet?"

    init_state = {
        "messages": [BaseMessage(type='text', content=user_query)],
    }

    result_state = graph.invoke(init_state)

    msgs = result_state.get("messages", [])
    if not msgs:
        print("No answer was generated.")
        sys.exit(1)

    last_ai: AIMessage = msgs[-1]
    print("Output:\n")
    print(last_ai.content)

if __name__ == "__main__":
    main()

Related Issues

Fixes #12, #34

@philschmid
Copy link
Contributor

Thank you for looking at this. Should be fixed in #109

@philschmid philschmid closed this Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configuration need reasoning_model field

2 participants