Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions dapr_agents/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from dapr_agents.agents.agent import Agent
from dapr_agents.agents.durableagent import DurableAgent
from dapr_agents.agents.memory_store import MemoryStore
from dapr_agents.executors import DockerCodeExecutor, LocalCodeExecutor
from dapr_agents.llm.dapr import DaprChatClient
from dapr_agents.llm.elevenlabs import ElevenLabsSpeechClient
Expand All @@ -23,7 +22,6 @@
__all__ = [
"Agent",
"DurableAgent",
"MemoryStore",
"DockerCodeExecutor",
"LocalCodeExecutor",
"ElevenLabsSpeechClient",
Expand Down
3 changes: 1 addition & 2 deletions dapr_agents/agents/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from .agent.agent import Agent
from .base import AgentBase
from .durableagent.agent import DurableAgent
from .memory_store import MemoryStore

__all__ = ["AgentBase", "Agent", "DurableAgent", "MemoryStore"]
__all__ = ["AgentBase", "Agent", "DurableAgent"]
24 changes: 6 additions & 18 deletions dapr_agents/agents/agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,6 @@ class Agent(AgentBase):
It integrates tools and processes them based on user inputs and task orchestration.
"""

def get_chat_history(self, task: Optional[str] = None) -> List[Dict[str, Any]]:
"""
Retrieves the chat history as a list of dictionaries.

Args:
task (Optional[str]): The task or query provided by the user.

Returns:
List[Dict[str, Any]]: The chat history as dictionaries.
"""
return self.memory_store.get_messages()

async def run(self, input_data: Optional[Union[str, Dict[str, Any]]] = None) -> Any:
"""
Runs the agent with the given input, supporting graceful shutdown.
Expand Down Expand Up @@ -81,15 +69,15 @@ async def _run_agent(
) -> Any:
"""
Internal method for running the agent logic.
Formats messages, updates conversation history, and drives the conversation loop.
Formats messages, updates memory, and drives the conversation loop.

Args:
input_data (Optional[Union[str, Dict[str, Any]]]): Input for the agent, can be a string or dict.
Returns:
Any: The result of the agent's conversation loop.
"""
logger.debug(
f"Agent run started with input: {input_data if input_data else 'Using session conversation context'}"
f"Agent run started with input: {input_data if input_data else 'Using memory context'}"
)

# Construct messages using only input_data; chat history handled internally
Expand All @@ -103,7 +91,7 @@ async def _run_agent(
if input_data and user_message_copy:
# Add the new user message to memory only if input_data is provided and user message exists
user_msg = UserMessage(content=user_message_copy.get("content", ""))
self.memory_store.add_message(user_msg)
self.memory.add_message(user_msg)

# Always print the last user message for context, even if no input_data is provided
if user_message_copy is not None:
Expand Down Expand Up @@ -172,8 +160,8 @@ async def run_and_record(tool_call: ToolCall) -> ToolMessage:
)
# Print the tool message for visibility
self.text_formatter.print_message(tool_message)
# Add tool message to storage
self.memory_store.add_message(tool_message)
# Add tool message to memory
self.memory.add_message(tool_message)
# Append tool message to the persistent audit log
tool_execution_record = ToolExecutionRecord(
tool_call_id=tool_id,
Expand Down Expand Up @@ -227,7 +215,7 @@ async def conversation(self, messages: List[Dict[str, Any]]) -> Any:
else:
assistant = response_message
self.text_formatter.print_message(assistant)
self.memory_store.add_message(assistant)
self.memory.add_message(assistant)

# Handle tool calls response
if assistant is not None and assistant.has_tool_calls():
Expand Down
Loading