Skip to content

Commit

Permalink
Switch from IsLastStep to RemainingSteps for research_assistant (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaC215 authored Nov 28, 2024
1 parent 8bfaa9a commit 58a56ce
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/agents/research_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from langchain_core.runnables import RunnableConfig, RunnableLambda, RunnableSerializable
from langgraph.checkpoint.memory import MemorySaver
from langgraph.graph import END, MessagesState, StateGraph
from langgraph.managed import IsLastStep
from langgraph.managed import RemainingSteps
from langgraph.prebuilt import ToolNode

from agents.llama_guard import LlamaGuard, LlamaGuardOutput, SafetyAssessment
Expand All @@ -22,7 +22,7 @@ class AgentState(MessagesState, total=False):
"""

safety: LlamaGuardOutput
is_last_step: IsLastStep
remaining_steps: RemainingSteps


web_search = DuckDuckGoSearchResults(name="WebSearch")
Expand Down Expand Up @@ -75,7 +75,7 @@ async def acall_model(state: AgentState, config: RunnableConfig) -> AgentState:
if safety_output.safety_assessment == SafetyAssessment.UNSAFE:
return {"messages": [format_safety_message(safety_output)], "safety": safety_output}

if state["is_last_step"] and response.tool_calls:
if state["remaining_steps"] < 2 and response.tool_calls:
return {
"messages": [
AIMessage(
Expand Down

0 comments on commit 58a56ce

Please sign in to comment.