-
I am using 0.4.6, I want the factory function to take runtime/agent_key as params, how to implement? |
Beta Was this translation helpful? Give feedback.
Answered by
ekzhu
Feb 12, 2025
Replies: 1 comment 3 replies
-
Can I use the code like this to pass runtime/agent to the factory? async def factory_wrapper_2(runtime, agent_id) -> T:
maybe_agent_instance = agent_factory(runtime, agent_id)
if inspect.isawaitable(maybe_agent_instance):
agent_instance = await maybe_agent_instance
else:
agent_instance = maybe_agent_instance
if type_func_alias(agent_instance) != expected_class:
raise ValueError("Factory registered using the wrong type.")
return agent_instance
self._agent_factories[type.type] = factory_wrapper_2 |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why do you need to pass the runtime and key? Inside the agent constructor you can already get the runtime and key from the
AgentInstantiationContext
: