Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions chatbot/src/ActivityTrace.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ function Step({ step, live, interrupted }) {
<span
className={`execution-step-target ${["read", "edit"].includes(face.kind) ? "is-file" : ""}`}
title={step.detail || target}
aria-live={pending && step.tool === "workspace_docker_build" ? "polite" : undefined}
>
{target}
</span>
Expand Down
2 changes: 2 additions & 0 deletions chatbot/src/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,8 @@ export function activityFace(step) {
return { kind: "verify", busy: "正在提交节点结果", done: "已提交节点结果" };
if (/workbench_workspace_open/.test(name))
return { kind: "workflow", busy: "正在打开工作区", done: "已打开工作区" };
if (name === "workspace_docker_build")
return { kind: "workflow", busy: "正在构建 Docker 镜像", done: "已构建 Docker 镜像" };
if (/workbench_delivery_register/.test(name))
return { kind: "workflow", busy: "正在登记交付", done: "已登记交付" };
if (/workbench_publish_artifact/.test(name))
Expand Down
19 changes: 19 additions & 0 deletions chatbot/tests/activity-trace-groups.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { describe, expect, test } from "vitest";
import ActivityTrace, { ReplyTimeline } from "../src/ActivityTrace.jsx";
import { mergeActivity } from "../src/activity.js";

const start = "2026-01-01T00:00:00Z";
const finish = "2026-01-01T00:01:05Z";
Expand All @@ -17,6 +18,24 @@ const tool = (id, detail, extra = {}) => ({
});

describe("Codex-style activity trace", () => {
test("Docker build progress updates one visible row and settles on completion", () => {
const build = { kind: "tool", tool: "workspace_docker_build", id: "build", at: start };
const steps = mergeActivity([], [{ data: { ...build, detail: "读取基础镜像信息" } }]);
const view = render(<ReplyTimeline steps={steps} startedAt={start} live />);
expect(screen.getByText("正在构建 Docker 镜像")).toBeVisible();
expect(screen.getByText("读取基础镜像信息")).toBeVisible();

const building = mergeActivity(steps, [{ data: { ...build, detail: "执行 Dockerfile 第 2/3 步" } }]);
view.rerender(<ReplyTimeline steps={building} startedAt={start} live />);
expect(screen.getAllByText("正在构建 Docker 镜像")).toHaveLength(1);
expect(screen.getByText("执行 Dockerfile 第 2/3 步")).toBeVisible();
expect(screen.queryByText("读取基础镜像信息")).toBeNull();

const done = mergeActivity(building, [{ data: { kind: "toolDone", id: "build", at: finish } }]);
view.rerender(<ReplyTimeline steps={done} startedAt={start} live />);
expect(screen.getByText("已构建 Docker 镜像")).toBeVisible();
});

test("the running round lists every step and folds once it finishes", async () => {
const steps = [
{ id: "t1", kind: "text", text: "先查澄清面板的前端代码。" },
Expand Down
6 changes: 4 additions & 2 deletions docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,15 @@ Access to the Docker socket is equivalent to root on the host. Two safeguards fo

### Slow networks: clone and image build limits

Cloning a repository and building a custom sandbox image report progress while they work, and their errors keep the last lines of git or Docker output. On the platform host the progress is recorded on the run. On an execution machine it is written to the runner's log, and only the final error reaches the platform. A step that prints nothing for its stall window is treated as hung and stopped. A step that keeps printing may be slow but is stopped only by a total limit. All settings take Go durations such as `90s` or `20m`; `0` turns a limit off. Each host reads its own environment, so set the clone limits on execution machines too.
Cloning a repository and building a custom sandbox image report progress while they work, and their errors keep the last lines of Git or Docker output. Conversations show the current Docker build step on the platform and on connected runners. A long, quiet Dockerfile step can continue until its caller or a configured limit stops the build. All settings take Go durations such as `90s` or `20m`. `0` turns a limit off. Set the variables on the platform process or execution machine that runs the command.

Runner conversation workspace preparation follows the conversation request's lifetime. Stopping the turn or losing the runner control connection cancels preparation.

| Setting | Default | Applies to |
|---|---|---|
| `AGENTFLOW_GIT_CLONE_STALL_TIMEOUT` | `5m` | `git clone` with no output. Not applied when the platform clones from a repository's local source path, whose final repack is silent. |
| `AGENTFLOW_GIT_CLONE_TIMEOUT` | off on the platform, `10m` on execution machines | Whole `git clone`. Execution machines keep their earlier fixed 10 minute limit as the default. |
| `AGENTFLOW_DOCKER_BUILD_STALL_TIMEOUT` | `10m` | `docker build` with no output. A quiet `RUN` step (a long compile) counts as no output. |
| `AGENTFLOW_DOCKER_BUILD_STALL_TIMEOUT` | off | Optional no-output limit for `docker build`. A quiet `RUN` step counts as no output. |
| `AGENTFLOW_DOCKER_BUILD_TIMEOUT` | off | Whole `docker build`. |

A clone that is stopped this way is not retried, since a retry would wait on the same network. When the execution host reaches GitHub or Debian mirrors slowly, point git at a proxy (`git config --global http.proxy`) and use a nearby package mirror in the Dockerfile rather than raising these limits.
Expand Down
15 changes: 15 additions & 0 deletions internal/domain/runner_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ type RunnerToolResponse struct {
Error string `json:"error,omitempty"`
}

// WorkspaceImageBuildProgress reports a build step without including Docker
// output, Dockerfile arguments, or environment variables.
type WorkspaceImageBuildProgress struct {
ID string `json:"id"`
Step string `json:"step,omitempty"`
Done bool `json:"done,omitempty"`
Failed bool `json:"failed,omitempty"`
}

type WorkspaceCheckpointTransfer struct {
ID string `json:"id,omitempty"`
Size int64 `json:"size,omitempty"`
Expand All @@ -139,6 +148,12 @@ type WorkspaceCheckpointTransfer struct {
Data []byte `json:"data,omitempty"`
}

// IsCancelableRunnerWorkspaceOperation identifies synchronous requests that
// hold a workspace fence. Conversation processes have their own stop protocol.
func IsCancelableRunnerWorkspaceOperation(op string) bool {
return IsWorkspaceCheckpointTransferOperation(op) || op == RunnerWorkspaceOperationCheckpoint || op == RunnerWorkspaceOperationPrepare
}

func IsWorkspaceCheckpointTransferOperation(op string) bool {
switch op {
case RunnerWorkspaceOperationCheckpointExport, RunnerWorkspaceOperationCheckpointRead, RunnerWorkspaceOperationCheckpointClose, RunnerWorkspaceOperationCheckpointUpload, RunnerWorkspaceOperationCheckpointAppend, RunnerWorkspaceOperationCheckpointCommit:
Expand Down
16 changes: 16 additions & 0 deletions internal/httpapi/assistant_activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,22 @@ func (l *assistantActivityLog) add(event assistantStreamEvent) {
}
event.Input = truncateRunes(event.Input, 8000)
event.Output = truncateRunes(event.Output, 8000)
if event.Kind == "tool" && event.Tool == assistantDockerBuildTool && event.ID != "" {
for i := len(l.events) - 1; i >= 0; i-- {
step := &l.events[i]
if step.Kind == "tool" && step.Tool == event.Tool && step.ID == event.ID {
detail := truncateRunes(event.Detail, 4000)
bytes := l.bytes - len(step.Detail) + len(detail)
if bytes > 512<<10 {
l.truncated = true
return
}
l.bytes = bytes
step.Detail = detail
return
}
}
}
size := len(event.Text) + len(event.Detail) + len(event.Input) + len(event.Output)
if len(l.events) >= 512 || l.bytes+size > 512<<10 {
l.truncated = true
Expand Down
1 change: 1 addition & 0 deletions internal/httpapi/assistant_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func (h *assistantHandlers) conversationExecutor(s *AgentToolSession, root strin
request := domain.RunnerWorkspaceRequest{Operation: domain.RunnerWorkspaceOperationConversationCLI}
workspace := ""
if s.RuntimeMode == domain.AssistantModeWorkspace {
ctx = withAssistantDockerBuildProgress(ctx, s)
runID := s.workspaceRun()
run, ok := h.repo.RunState(runID)
if !ok {
Expand Down
1 change: 1 addition & 0 deletions internal/httpapi/assistant_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ func (h *agentToolGateway) mainBotWorkspaceLease(ctx context.Context, s *AgentTo
if h.engine == nil {
return ctx, nil, release, nil
}
ctx = withAssistantDockerBuildProgress(ctx, s)
if s.workspaceTurn != nil {
ctx, err := s.workspaceTurn.lease(ctx, runID)
if err != nil {
Expand Down
29 changes: 29 additions & 0 deletions internal/httpapi/assistant_workspace_build.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package httpapi

import (
"context"
"time"

"agentflow/internal/domain"
"agentflow/internal/runtime"
)

const assistantDockerBuildTool = "workspace_docker_build"

func withAssistantDockerBuildProgress(ctx context.Context, session *AgentToolSession) context.Context {
if session.Notify == nil || runtime.DockerBuildProgressObserver(ctx) != nil {
return ctx
}
return runtime.WithDockerBuildProgress(ctx, func(update domain.WorkspaceImageBuildProgress) {
if ctx.Err() != nil || update.ID == "" {
return
}
id := "docker-build-" + update.ID
at := time.Now().UTC()
if update.Done {
session.Notify("thought", assistantStreamEvent{Kind: "toolDone", ID: id, At: &at, Failed: update.Failed})
return
}
session.Notify("thought", assistantStreamEvent{Kind: "tool", Tool: assistantDockerBuildTool, ID: id, At: &at, Detail: update.Step})
})
}
Loading
Loading