fix: Agent 迭代数从未更新,始终显示 0/N
This commit is contained in:
@@ -38,6 +38,11 @@ export function useAgentStream(): void {
|
||||
|
||||
const store = useAgentStore.getState();
|
||||
|
||||
// 每次收到迭代号时同步更新
|
||||
if (data.iteration != null) {
|
||||
store.setCurrentIteration(data.iteration);
|
||||
}
|
||||
|
||||
switch (data.type) {
|
||||
// 思考开始
|
||||
case 'thinking_start':
|
||||
|
||||
@@ -105,6 +105,7 @@ interface AgentState {
|
||||
updateTokenUsage: (usage: Partial<TokenUsage>) => void;
|
||||
setProvider: (provider: string, model: string) => void;
|
||||
setMaxIterations: (max: number) => void;
|
||||
setCurrentIteration: (n: number) => void;
|
||||
saveTraceData: () => void;
|
||||
clearMessages: () => void;
|
||||
abort: () => void;
|
||||
@@ -305,6 +306,8 @@ export const useAgentStore = create<AgentState>((set, get) => ({
|
||||
|
||||
setMaxIterations: (max) => set({ maxIterations: max }),
|
||||
|
||||
setCurrentIteration: (currentIteration) => set({ currentIteration }),
|
||||
|
||||
saveTraceData: () => {
|
||||
const { currentSessionId, traceSteps, tokenUsage } = get();
|
||||
if (currentSessionId && window.metona?.sessions?.saveTrace) {
|
||||
|
||||
Reference in New Issue
Block a user