Trying out 0.5.0 with single run agent and now get...
# koog-agentic-framework
j
Trying out 0.5.0 with single run agent and now getting following the 2nd time I run the agent. Consistent with that I guess i'm not seeing
onAgentCompleted
callback being invoked (as it had been before). I realise of course that version hasn't officially been released but just fyi in case of use.
Copy code
Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: Agent was already started
	at ai.koog.agents.core.agent.StatefulSingleUseAIAgent.run(StatefulSingleUseAIAgent.kt:103)
I'm reusing the
AIAgent
instance....is expectation now perhaps that it has to be recreated for each run?
v
Yes! agents are now explicitly single-use
Previously the contract of AIAgent was kinda single use but not really : you could re-run them sequentially, but they were throwing an exception when running in parallel (affecting parallel tool calls with Agent.asTool()) Now you can use
AIAgentService
which has all similar constructors as
AIAgent
(so you can literally just append “Service” after “AIAgent” — and it should construct you a matching agent service), and then it has
createAgent(/** id = "optional-id" */)
that would give you an instance of single-use
AIAgent
or you can use
createAgentAndRun(input = "input for your agent")
Also you can now monitor agent state (using
agent.getState()
, or roll it back using persistence() in runtime)
👍 2
AIAgent
is now essentially a single-run state-machine that can keep track of it’s state, take input and eventually produce some output (actually same as before, but now with state management and with explicit single-use contract)
AIAgentService
is a service for launching multiple agentic flows.