Stamp observability metadata/tags on preset automation conversations - #355
Draft
juanmichelini wants to merge 1 commit into
Draft
Stamp observability metadata/tags on preset automation conversations#355juanmichelini wants to merge 1 commit into
juanmichelini wants to merge 1 commit into
Conversation
Preset scripts create their RemoteConversation directly against the sandbox agent server, bypassing the app-server start path, so their Laminar traces carry no origin signal and are indistinguishable from regular UI conversations. Both preset scripts (prompt and plugin) now pass observability_metadata and observability_tags to Conversation(): - trigger=automation metadata + trigger:automation tag, matching the app-server convention so automation vs. UI traffic splits uniformly - automation_trigger (cron/event), automation_id, automation_name and automation_run_id from AUTOMATION_EVENT_PAYLOAD / env for drill-down - plugin preset additionally records experiment_id / experiment_variant for A/B analysis Gated on an inspect.signature check (same pattern as the existing user_id gate) so sandboxes running older SDK versions silently skip the new kwargs instead of failing. Co-authored-by: openhands <openhands@all-hands.dev>
Contributor
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.
Why
Automation-run sessions and regular UI conversations are indistinguishable in Laminar today. Traces only carry
session_id(the conversation UUID) — no origin signal in metadata or tags — so there's no way to filter automation traffic out of (or into) trace views, cost analysis, or signals.Preset scripts create their
RemoteConversationdirectly against the sandbox agent server, bypassing the app-server start path, so any origin stamping has to happen here. The SDK plumbing already exists (Conversation(observability_metadata=..., observability_tags=...)→Laminar.set_trace_metadata/ root span tags) — the presets just weren't using it.What
Both preset scripts (
presets/prompt/sdk_main.py,presets/plugin/sdk_main.py) now pass observability context toConversation():triggerautomationtrigger:automationautomation_triggercron/eventAUTOMATION_EVENT_PAYLOAD.triggerautomation_trigger:<type>automation_id/automation_nameAUTOMATION_EVENT_PAYLOADautomation_run_idAUTOMATION_RUN_IDenvexperiment_id/experiment_variantThe kwargs are gated on an
inspect.signaturecheck (same pattern as the existing_conversation_supports_user_id()gate), so sandboxes running older SDK versions silently skip them instead of raising.Example Laminar query after this lands:
or filter by the
trigger:automationtag, or drill into a single automation viametadata.automation_name.Notes
ConversationTriggerinto the app-server observability context, covering conversations started throughPOST /api/v1/app-conversations(GUI, Slack, Jira, resolver, and API-triggered automation conversations).Testing
_build_observability_contextfrom both scripts and unit-tested it directly (full payload, empty payload, cron-only) — all passpytest tests/test_preset_router.py tests/test_ab_testing_integration.py— 114 passedruff check/ruff format --checkclean (presets dir is excluded from lint perpyproject.toml; verified the scripts are unchanged-lint-parity with base)This PR was created by an AI agent (OpenHands) on behalf of the user.
@juanmichelini can click here to continue refining the PR