File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -775,7 +775,7 @@ func (s *Server) createSession(c echo.Context) error {
775775 return c .JSON (http .StatusBadRequest , map [string ]string {"error" : "invalid request body" })
776776 }
777777
778- sess := session .New ()
778+ sess := session .New (session . WithMaxIterations ( sessionTemplate . MaxIterations ) )
779779 sess .ToolsApproved = sessionTemplate .ToolsApproved
780780
781781 if err := s .sessionStore .AddSession (c .Request ().Context (), sess ); err != nil {
@@ -843,12 +843,17 @@ func (s *Server) runAgent(c echo.Context) error {
843843
844844 t , exists := s .teams [agentFilename ]
845845 if ! exists {
846- return c .JSON (http .StatusNotFound , map [string ]string {"error" : fmt .Sprintf ("runtime not found: %s" , agentFilename )})
846+ return c .JSON (http .StatusNotFound , map [string ]string {"error" : fmt .Sprintf ("team not found: %s" , agentFilename )})
847847 }
848848 sess , err := s .sessionStore .GetSession (c .Request ().Context (), sessionID )
849849 if err != nil {
850850 return c .JSON (http .StatusNotFound , map [string ]string {"error" : "session not found" })
851851 }
852+ // Only set max iterations the first time the session is run
853+ // since on creation we can accept an empty sessionTemplate
854+ if len (sess .Messages ) == 0 && sess .MaxIterations == 0 && t .Agent (currentAgent ).MaxIterations () > 0 {
855+ sess .MaxIterations = t .Agent (currentAgent ).MaxIterations ()
856+ }
852857
853858 rt , exists := s .runtimes [sess .ID ]
854859 if ! exists {
You can’t perform that action at this time.
0 commit comments