Problem
Agent has a rich set of lifecycle callbacks — on_usage, on_retry, on_provider_fallback, on_compact_start, on_compact_end, on_trace_event, on_request, on_turn_end — that are useful for monitoring, logging, and building custom UIs. However, none of these are exposed through Config or CodeLoop. Library users who want to hook into these events must reach into flow.CodeLoop.agent directly (bypassing the public API) or subclass Agent.
flow = CodeLoop(config=Config(...))
flow.agent.on_usage = my_callback # private, undocumented
The VS Code extension and any third-party integrations that embed CodeLoop as a library have no stable hook surface.
Steps to reproduce / context
A library user wants to display a token counter:
flow = CodeLoop(config=Config(...))
# No public way to register on_usage without touching flow.agent internals
Expected behavior
Config should accept the same lifecycle callbacks as Agent and pass them through. CodeLoop.run() should set them on the agent before each run (in case Config is mutated after construction).
Suggested fix
Add optional callback parameters to Config.__init__() and store them. In CodeLoop.__init__() (or run()), assign them to self.agent.*. Alternatively, expose a CodeLoop.on(event_name, callback) registration method for a cleaner public API. This is additive and non-breaking.
Problem
Agenthas a rich set of lifecycle callbacks —on_usage,on_retry,on_provider_fallback,on_compact_start,on_compact_end,on_trace_event,on_request,on_turn_end— that are useful for monitoring, logging, and building custom UIs. However, none of these are exposed throughConfigorCodeLoop. Library users who want to hook into these events must reach intoflow.CodeLoop.agentdirectly (bypassing the public API) or subclassAgent.The VS Code extension and any third-party integrations that embed
CodeLoopas a library have no stable hook surface.Steps to reproduce / context
A library user wants to display a token counter:
Expected behavior
Configshould accept the same lifecycle callbacks asAgentand pass them through.CodeLoop.run()should set them on the agent before each run (in caseConfigis mutated after construction).Suggested fix
Add optional callback parameters to
Config.__init__()and store them. InCodeLoop.__init__()(orrun()), assign them toself.agent.*. Alternatively, expose aCodeLoop.on(event_name, callback)registration method for a cleaner public API. This is additive and non-breaking.