9p: make ctl sync, guard non-stop commands when agent is running
ctl is no longer in the async bucket. stop is always instant. Slash commands forwarded via Submit are synchronous for recognized commands. Unrecognized input is rejected with Rerror when the agent is running to prevent accidentally starting an agent turn.
This commit is contained in:
parent
81f7379fb6
commit
69e5bd18d9
|
|
@ -754,7 +754,7 @@ func (s *Server) isAsyncWrite(path string) bool {
|
|||
return false
|
||||
}
|
||||
switch pathBase(path) {
|
||||
case "prompt", "enqueue", "ctl":
|
||||
case "prompt", "enqueue":
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
|
@ -891,10 +891,17 @@ func (s *Server) handleWrite(path, input string) error {
|
|||
switch input {
|
||||
case "stop":
|
||||
sess.core.Interrupt(agent.ErrInterrupted)
|
||||
return nil
|
||||
default:
|
||||
// Forward as slash command. Submit handles it synchronously
|
||||
// for recognized commands; unrecognized ones fall through to
|
||||
// start an agent turn, which we must not do from ctl.
|
||||
if sess.core.IsRunning() {
|
||||
return fmt.Errorf("agent is running")
|
||||
}
|
||||
sess.core.Submit(sess.ctx, "/"+input, publish)
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
|
||||
case "backend":
|
||||
if sess.core.IsRunning() {
|
||||
|
|
|
|||
Reference in New Issue