rough-hairdresser-81331
06/26/2025, 8:43 PMtall-airline-16756
06/26/2025, 8:43 PMtall-airline-16756
06/26/2025, 8:43 PMrough-hairdresser-81331
06/26/2025, 8:44 PMclass BaseAgent(Agent):
def __init__(self, agent_config: Optional[dict] = None, **kwargs):
super().__init__(**kwargs)
self.agent_config = agent_config or {}
async def on_enter(self) -> None:
agent_name = self.__class__.__name__
<http://logger.info|logger.info>(f"entering task {agent_name}")
userdata: UserData = self.session.userdata
chat_ctx = self.chat_ctx.copy()
print(f"Chat context for {agent_name}: {chat_ctx.items}")
# add the previous agent's chat history to the current agent
if isinstance(userdata.prev_agent, Agent):
truncated_chat_ctx = userdata.prev_agent.chat_ctx.copy(
exclude_instructions=True, exclude_function_call=False
)
print(f"Truncated chat context: {truncated_chat_ctx.items}")
existing_ids = {item.id for item in chat_ctx.items}
items_copy = [
item for item in truncated_chat_ctx.items if item.id not in existing_ids
]
chat_ctx.items.extend(items_copy)
await self.update_chat_ctx(chat_ctx)
await self.enter()
tall-airline-16756
06/26/2025, 8:44 PMrough-hairdresser-81331
06/26/2025, 8:46 PMclass GreeterAgent(BaseAgent):
def __init__(self, agent_config: dict) -> None:
instructions = agent_config.get(
"instructions", DEFAULT_GREETER_AGENT_INSTRUCTIONS
)
super().__init__(
instructions=instructions,
)
but I also want them to have the general instructions too and that is applicable to all agentstall-airline-16756
06/26/2025, 8:47 PMrough-hairdresser-81331
06/26/2025, 8:47 PMtall-airline-16756
06/26/2025, 8:48 PM