feat: add runKind field to differentiate delegation/announce runs from user-initiated

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
viettranxandClaude Opus 4.6 committed 2026-03-05 18:59:51 +07:00
1 parent 5664135c8a
commit 8862842b46
5 files changed
+23

No files matched your search

+2
View File
@@ -416,6 +416,7 @@ func consumeInboundMessages(ctx context.Context, msgBus *bus.MessageBus, agents
LocalKey: origLocalKey,
UserID: announceUserID,
RunID: fmt.Sprintf("announce-%s", msg.SenderID),
RunKind: "announce",
Stream: false,
ParentTraceID: parentTraceID,
ParentRootSpanID: parentRootSpanID,
@@ -535,6 +536,7 @@ func consumeInboundMessages(ctx context.Context, msgBus *bus.MessageBus, agents
LocalKey: origLocalKey,
UserID: announceUserID,
RunID: fmt.Sprintf("delegate-announce-%s", msg.Metadata["delegation_id"]),
RunKind: "announce",
Stream: false,
ParentTraceID: parentTraceID,
ParentRootSpanID: parentRootSpanID,
+1
View File
@@ -336,6 +336,7 @@ func wireManagedExtras(
Stream: req.Stream,
ExtraSystemPrompt: req.ExtraSystemPrompt,
MaxIterations: req.MaxIterations,
RunKind: "delegation",
DelegationID: req.DelegationID,
TeamID: req.TeamID,
TeamTaskID: req.TeamTaskID,
+4
View File
@@ -109,6 +109,7 @@ type AgentEvent struct {
Type string `json:"type"` // "run.started", "run.completed", "run.failed", "chunk", "tool.call", "tool.result"
AgentID string `json:"agentId"`
RunID string `json:"runId"`
RunKind string `json:"runKind,omitempty"` // "delegation", "announce" — omitted for user-initiated runs
Payload interface{} `json:"payload,omitempty"`
// Delegation context (omitempty — only present when agent runs inside a delegation)
@@ -274,6 +275,9 @@ type RunRequest struct {
TraceTags []string // additional tags for the trace (e.g. "cron")
MaxIterations int // per-request override (0 = use agent default, must be lower)
// Run classification
RunKind string // "delegation", "announce" — empty for user-initiated runs
// Delegation context (set when running as a delegate agent)
DelegationID string // delegation ID for event correlation
TeamID string // team ID (if delegation is team-scoped)
@@ -27,6 +27,7 @@ function RunEventCard({ p, resolveAgent }: { p: EnrichedAgentEventPayload; resol
<div className="space-y-1 text-sm">
<div className="flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-0.5">
<span className="truncate font-medium">{resolveAgent(p.agentId)}</span>
{p.runKind && <RunKindBadge kind={p.runKind} />}
</div>
{message && (
@@ -64,12 +65,14 @@ function ToolEventCard({ p, resolveAgent }: { p: EnrichedAgentEventPayload; reso
<Badge variant={isError ? "destructive" : "success"} className="shrink-0 text-xs">
{isError ? "error" : "ok"}
</Badge>
{p.runKind && <RunKindBadge kind={p.runKind} />}
</>
) : (
<>
<span className="truncate font-medium">{agentName}</span>
<span className="shrink-0 text-muted-foreground">&rarr;</span>
{toolName && <span className="truncate font-mono font-medium">{toolName}</span>}
{p.runKind && <RunKindBadge kind={p.runKind} />}
</>
)}
</div>
@@ -143,3 +146,15 @@ function PillId({ label, id }: { label: string; id: string }) {
</span>
);
}
function RunKindBadge({ kind }: { kind: string }) {
const colors: Record<string, string> = {
delegation: "bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300",
announce: "bg-orange-100 text-orange-700 dark:bg-orange-900/40 dark:text-orange-300",
};
return (
<span className={`shrink-0 rounded px-1.5 py-0.5 text-xs font-medium ${colors[kind] ?? "bg-muted text-muted-foreground"}`}>
{kind}
</span>
);
}
+1
View File
@@ -195,6 +195,7 @@ export interface EnrichedAgentEventPayload {
type: string;
agentId: string;
runId: string;
runKind?: string; // "delegation", "announce" — omitted for user-initiated runs
payload?: {
content?: string;
message?: string;