[code-simplifier] Code Simplification#1927
Conversation
Changed Files
|
Reviewer's GuideRefactors agent and MCP setup to reuse structured configuration and prompt helpers, simplifies response streaming to only manage chat history while centralizing tool-call metadata handling, and consolidates MCP and directory validation logic in settings for cleaner, more robust configuration handling. Sequence diagram for updated generate_response event handlingsequenceDiagram
actor User
participant Builder
participant Agent
User->>Builder: generate_response(message, history)
Builder->>Builder: _setup_agent()
Builder->>Agent: stream_events(message, history)
loop for each response
Agent-->>Builder: RunContentEvent
alt response is RunContentEvent
Builder->>Builder: history.append(ChatMessage(role="assistant", content))
else response is ToolCallStartedEvent or ToolCallCompletedEvent
Builder->>Builder: metadata = MetadataDict(...)
Builder->>Builder: history.append(ChatMessage(role="assistant", content, metadata))
alt ToolCallCompletedEvent and not tool_call_error
alt tool.tool_name == generate_audio_for_text
Builder->>Builder: history.append(Audio(tool.result, ...))
else tool.tool_name == generate_video_mcp
Builder->>Builder: history.append(Video(tool.result, ...))
else
Builder->>Builder: raise Error
end
end
end
Builder-->>User: yield history
end
Builder->>Builder: _close()
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
| metadata["duration"] = tool.created_at | ||
| else: | ||
| metadata["log"] = ( | ||
| "Tool Call Failed" |
🔍 Vulnerabilities of
|
| digest | sha256:c673eb8ca0fa1d8f9a7fcb82404fa5745fced330b479a9fa6363324a9217efa9 |
| vulnerabilities | |
| platform | linux/amd64 |
| size | 271 MB |
| packages | 425 |
# Dockerfile (1:14)
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:1af610c4a70668dad46159ee178b20378c79a49b554f76405670fc442d30183a AS builder
ARG INSTALL_SOURCE
ARG PYTHON_VERSION
# skipcq: DOK-DL3018
RUN apk add --no-cache build-base git uv
USER nonroot
RUN --mount=type=cache,target=/root/.cache/uv \
uv tool install ${INSTALL_SOURCE} --python ${PYTHON_VERSION}
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:1af610c4a70668dad46159ee178b20378c79a49b554f76405670fc442d30183a AS production
Description
Description | ||||||||||||||||||||||||
# Dockerfile (1:14)
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:1af610c4a70668dad46159ee178b20378c79a49b554f76405670fc442d30183a AS builder
ARG INSTALL_SOURCE
ARG PYTHON_VERSION
# skipcq: DOK-DL3018
RUN apk add --no-cache build-base git uv
USER nonroot
RUN --mount=type=cache,target=/root/.cache/uv \
uv tool install ${INSTALL_SOURCE} --python ${PYTHON_VERSION}
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:1af610c4a70668dad46159ee178b20378c79a49b554f76405670fc442d30183a AS production
Description
Description | ||||||||||||||||||||||||
# Dockerfile (1:14)
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:1af610c4a70668dad46159ee178b20378c79a49b554f76405670fc442d30183a AS builder
ARG INSTALL_SOURCE
ARG PYTHON_VERSION
# skipcq: DOK-DL3018
RUN apk add --no-cache build-base git uv
USER nonroot
RUN --mount=type=cache,target=/root/.cache/uv \
uv tool install ${INSTALL_SOURCE} --python ${PYTHON_VERSION}
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:1af610c4a70668dad46159ee178b20378c79a49b554f76405670fc442d30183a AS production
Description
Description | ||||||||||||||||||||||||
# Dockerfile (1:14)
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:1af610c4a70668dad46159ee178b20378c79a49b554f76405670fc442d30183a AS builder
ARG INSTALL_SOURCE
ARG PYTHON_VERSION
# skipcq: DOK-DL3018
RUN apk add --no-cache build-base git uv
USER nonroot
RUN --mount=type=cache,target=/root/.cache/uv \
uv tool install ${INSTALL_SOURCE} --python ${PYTHON_VERSION}
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:1af610c4a70668dad46159ee178b20378c79a49b554f76405670fc442d30183a AS production
Description
Description | ||||||||||||||||||||||||
# Dockerfile (1:14)
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:1af610c4a70668dad46159ee178b20378c79a49b554f76405670fc442d30183a AS builder
ARG INSTALL_SOURCE
ARG PYTHON_VERSION
# skipcq: DOK-DL3018
RUN apk add --no-cache build-base git uv
USER nonroot
RUN --mount=type=cache,target=/root/.cache/uv \
uv tool install ${INSTALL_SOURCE} --python ${PYTHON_VERSION}
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:1af610c4a70668dad46159ee178b20378c79a49b554f76405670fc442d30183a AS production
Description
Description | ||||||||||||||||||||||||
# Dockerfile (1:14)
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:1af610c4a70668dad46159ee178b20378c79a49b554f76405670fc442d30183a AS builder
ARG INSTALL_SOURCE
ARG PYTHON_VERSION
# skipcq: DOK-DL3018
RUN apk add --no-cache build-base git uv
USER nonroot
RUN --mount=type=cache,target=/root/.cache/uv \
uv tool install ${INSTALL_SOURCE} --python ${PYTHON_VERSION}
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:1af610c4a70668dad46159ee178b20378c79a49b554f76405670fc442d30183a AS production
Description
Description | ||||||||||||||||||||||||
# Dockerfile (1:14)
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:1af610c4a70668dad46159ee178b20378c79a49b554f76405670fc442d30183a AS builder
ARG INSTALL_SOURCE
ARG PYTHON_VERSION
# skipcq: DOK-DL3018
RUN apk add --no-cache build-base git uv
USER nonroot
RUN --mount=type=cache,target=/root/.cache/uv \
uv tool install ${INSTALL_SOURCE} --python ${PYTHON_VERSION}
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:1af610c4a70668dad46159ee178b20378c79a49b554f76405670fc442d30183a AS production
Description
Description | ||||||||||||||||||||||||
# Dockerfile (1:14)
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:1af610c4a70668dad46159ee178b20378c79a49b554f76405670fc442d30183a AS builder
ARG INSTALL_SOURCE
ARG PYTHON_VERSION
# skipcq: DOK-DL3018
RUN apk add --no-cache build-base git uv
USER nonroot
RUN --mount=type=cache,target=/root/.cache/uv \
uv tool install ${INSTALL_SOURCE} --python ${PYTHON_VERSION}
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:1af610c4a70668dad46159ee178b20378c79a49b554f76405670fc442d30183a AS production
Description
Description | ||||||||||||||||||||||||
# Dockerfile (1:14)
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:1af610c4a70668dad46159ee178b20378c79a49b554f76405670fc442d30183a AS builder
ARG INSTALL_SOURCE
ARG PYTHON_VERSION
# skipcq: DOK-DL3018
RUN apk add --no-cache build-base git uv
USER nonroot
RUN --mount=type=cache,target=/root/.cache/uv \
uv tool install ${INSTALL_SOURCE} --python ${PYTHON_VERSION}
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:1af610c4a70668dad46159ee178b20378c79a49b554f76405670fc442d30183a AS production
Description
Description | ||||||||||||||||||||||||
# Dockerfile (1:14)
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:1af610c4a70668dad46159ee178b20378c79a49b554f76405670fc442d30183a AS builder
ARG INSTALL_SOURCE
ARG PYTHON_VERSION
# skipcq: DOK-DL3018
RUN apk add --no-cache build-base git uv
USER nonroot
RUN --mount=type=cache,target=/root/.cache/uv \
uv tool install ${INSTALL_SOURCE} --python ${PYTHON_VERSION}
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:1af610c4a70668dad46159ee178b20378c79a49b554f76405670fc442d30183a AS production
Description
Description | ||||||||||||||||||||||||
# Dockerfile (1:14)
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:1af610c4a70668dad46159ee178b20378c79a49b554f76405670fc442d30183a AS builder
ARG INSTALL_SOURCE
ARG PYTHON_VERSION
# skipcq: DOK-DL3018
RUN apk add --no-cache build-base git uv
USER nonroot
RUN --mount=type=cache,target=/root/.cache/uv \
uv tool install ${INSTALL_SOURCE} --python ${PYTHON_VERSION}
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:1af610c4a70668dad46159ee178b20378c79a49b554f76405670fc442d30183a AS production
Description
Description | ||||||||||||||||||||||||
# Dockerfile (28:28)
COPY --from=builder --chown=nonroot:nonroot --chmod=555 /home/nonroot/.local/ /home/nonroot/.local/
Description
Description
| ||||||||||||||||||||||||
# Dockerfile (28:28)
COPY --from=builder --chown=nonroot:nonroot --chmod=555 /home/nonroot/.local/ /home/nonroot/.local/
Description
| ||||||||||||||||||||||||
# Dockerfile (28:28)
COPY --from=builder --chown=nonroot:nonroot --chmod=555 /home/nonroot/.local/ /home/nonroot/.local/
Description
Description
| ||||||||||||||||||||||||
# Dockerfile (28:28)
COPY --from=builder --chown=nonroot:nonroot --chmod=555 /home/nonroot/.local/ /home/nonroot/.local/
Description
|
|
|
This pull request was automatically closed because it expired on 2026-05-22T07:48:20.119Z.
|



Caution
agentic threat detected
Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.
Details
The threat detection results could not be parsed.
Review the workflow run logs for details.
Simplifying code in builder.py and settings.py
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
localhostSee Network Configuration for more information.
Add this agentic workflows to your repo
To install this agentic workflow, run
Summary by Sourcery
Simplify agent setup, MCP configuration handling, and response generation while consolidating validation logic and directory management.
Enhancements: