Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Fix saving steps to db
Tomas Valenta1d5dc871e08c
diff --git a/api-client/AgentRun.ts b/api-client/AgentRun.tsindex ab691788d..5c930b226 100644--- a/api-client/AgentRun.ts+++ b/api-client/AgentRun.ts@@ -87,7 +87,6 @@ export class AgentRun {step.output = edit.outputstep.logs = []- // return steps without steps after edited stepreturn steps.slice(0, edit.stepIdx + 1)}}diff --git a/api-service/agent/base.py b/api-service/agent/base.pyindex edd829179..9cdafed6b 100644--- a/api-service/agent/base.py+++ b/api-service/agent/base.py@@ -2,8 +2,8 @@ import asyncioimport uuidfrom abc import abstractmethod-from typing import Any, Dict, List, Literal, Tuple, cast-from agent.output.parse_output import Log, ThoughtLog, ToolLog+from typing import Any, Dict, List, Literal, cast+from agent.output.parse_output import ToolLogfrom agent.output.output_stream_parser import OutputStreamParser, Stepfrom agent.output.token_callback_handler import TokenCallbackHandlerfrom agent.output.work_queue import WorkQueue@@ -161,6 +161,7 @@ class AgentRun:on_workload=lambda steps: db.upsert_deployment_steps(run_id=self.run_id,steps=steps,+ project_id=project_id,))@@ -317,14 +318,14 @@ class AgentRun:self.llm_generation.cancel()await self._close()- async def rewrite_steps(self, steps: List[Step], buffered_step: Step):+ async def rewrite_steps(self, steps: List[Step]):print("Rewrite agent run steps")await self.pause()self.rewriting_steps = Trueself.llm_generation.cancel()self._output_parser = OutputStreamParser(tool_names=self.tool_names,- steps=steps,- buffered_step=buffered_step,+ steps=steps[:-1],+ buffered_step=steps[-1],)await self.resume()diff --git a/api-service/database/database.py b/api-service/database/database.pyindex a2c289859..7ba0d3d20 100644--- a/api-service/database/database.py+++ b/api-service/database/database.py@@ -41,12 +41,14 @@ class Database:async def upsert_deployment_steps(self,run_id: str,+ project_id: str,steps: List[Step],) -> None:await self.client.table(TABLE_DEPLOYMENTS).upsert({"id": run_id,- "steps": steps,+ "logs": steps,+ "project_id": project_id,},on_conflict="id",).execute()diff --git a/components/Editor/Sidebar/Agent/index.tsx b/components/Editor/Sidebar/Agent/index.tsxindex 3a5699770..2d61f9c22 100644--- a/components/Editor/Sidebar/Agent/index.tsx+++ b/components/Editor/Sidebar/Agent/index.tsx@@ -148,7 +148,7 @@ function Agent({/></div></div>- {!agentState &&+ {!steps &&<divclassName="self-centerdiff --git a/components/Editor/Sidebar/index.tsx b/components/Editor/Sidebar/index.tsxindex 590335d06..2f86026fc 100644--- a/components/Editor/Sidebar/index.tsx+++ b/components/Editor/Sidebar/index.tsx@@ -5,6 +5,8 @@ import { useStateStore } from 'state/StoreProvider'import { getModelArgs } from 'state/model'import useModelProviderArgs from 'hooks/useModelProviderArgs'import { evaluatePrompt } from 'state/prompt'+import { Step } from 'api-client/AgentRun'+import useAgentRun from 'hooks/useAgentRun'import Agent from './Agent'import Envs from './Envs'@@ -12,7 +14,6 @@ import Model from './Model'import Prompt from './Prompt'import { MenuSection } from '../SidebarMenu'-import useAgentRun from 'hooks/useAgentRun'export interface Props {project: projects & {@@ -41,7 +42,7 @@ function Sidebar({// TODO: Change logs to steps in dbconst lastRunLogs = project.deployments.length === 1 ? project.deployments[0] : undefined- const steps = newSteps || lastRunLogs?.logs+ const steps = newSteps || lastRunLogs?.logs as Step[] | undefinedasync function run() {if (!modelConfig) {diff --git a/hooks/useAgentRun.ts b/hooks/useAgentRun.tsindex 3cf9dc92a..26f0b0857 100644--- a/hooks/useAgentRun.ts+++ b/hooks/useAgentRun.ts@@ -7,7 +7,7 @@ import { baseUrl } from 'api-client/api'function useAgentRun() {const [agentRun, setAgentRun] = useState<AgentRun>()- const [steps, setSteps] = useState<Step[]>([])+ const [steps, setSteps] = useState<Step[]>()const [agentState, setAgentState] = useState<deployment_state>()const start = useCallback(async (projectID: string, modelConfig: ModelConfig) => {