fix(artifacts): render standalone artifacts (emit type=artifact message)#22
Open
AndrewKirkovski wants to merge 1 commit into
Open
fix(artifacts): render standalone artifacts (emit type=artifact message)#22AndrewKirkovski wants to merge 1 commit into
AndrewKirkovski wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
control_handlers.control_artifactspersists the artifact (assigns auuid.v7()id) but surfaced it to the client only as aMSG_TYPE.SYSTEMmessage (system_action = artifact_created) plus a sessionartifact_addedupdate.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 asystem_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:
…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_createdmessage +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).