Skip to content

fix(artifacts): render standalone artifacts (emit type=artifact message)#22

Open
AndrewKirkovski wants to merge 1 commit into
masterfrom
fix/render-standalone-artifact-message
Open

fix(artifacts): render standalone artifacts (emit type=artifact message)#22
AndrewKirkovski wants to merge 1 commit into
masterfrom
fix/render-standalone-artifact-message

Conversation

@AndrewKirkovski

@AndrewKirkovski AndrewKirkovski commented Jun 10, 2026

Copy link
Copy Markdown

Problem

control_handlers.control_artifacts persists the artifact (assigns a uuid.v7() id) but surfaced it to the client only as a MSG_TYPE.SYSTEM message (system_action = artifact_created) plus a session artifact_added update.

Chat front-ends (e.g. the gen-2-chat web host) render a standalone artifact card from a message with type = 'artifact' + metadata.artifact_id, and have no handler for a system_action = 'artifact_created' system message. As a result, standalone artifacts (instructions = false, the default) never rendered in the chat thread — only the tool-call badge showed.

Fix

Emit a dedicated artifact message:

ctx.writer:add_message(consts.MSG_TYPE.ARTIFACT, artifact_data.title, { artifact_id = artifact_id })

gated to instructions == false. Inline artifacts (instructions = true) are rendered via the <artifact id="…"/> tag the agent embeds in its reply (the instructions block above), so emitting an artifact message for the inline case too would render the same artifact twice. The gate makes the two paths mutually exclusive.

The existing SYSTEM/artifact_created message + update_session({ artifact_added }) are kept (agent context / session signalling).

Verification

Against the gen-2-chat host + app-template (OpenRouter-backed Sonnet): a standalone mermaid artifact now renders as a card in the chat; an inline-artifact request produces no duplicate (0 standalone cards).

…render

`control_artifacts` persisted the artifact and emitted only a
SYSTEM/artifact_created message (+ session update artifact_added). Chat
front-ends render a standalone artifact card from a message with
type='artifact' + metadata.artifact_id, and have no handler for the
system_action='artifact_created' message — so standalone artifacts
(instructions=false) never rendered in the chat thread.

Add `ctx.writer:add_message(MSG_TYPE.ARTIFACT, title, { artifact_id })`,
gated to instructions==false. Inline artifacts (instructions=true) are
rendered via the <artifact id="…"/> tag the agent embeds in its reply,
so the gate prevents the same artifact rendering twice.

Verified against gen-2-chat host: standalone mermaid artifact renders as
a card; inline path produces no duplicate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant