@noetic-tools/core 1.2.3 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -22,4 +22,12 @@ export declare const NoeticAttr: {
|
|
|
22
22
|
readonly WORKFLOW_EDGES: "noetic.workflow.edges";
|
|
23
23
|
/** Id of the declared workflow node an `llm.call`/`tool.call` span belongs to. */
|
|
24
24
|
readonly NODE_ID: "noetic.node.id";
|
|
25
|
+
/**
|
|
26
|
+
* Conversation/session this run belongs to (the run's `ctx.threadId`). Stamped
|
|
27
|
+
* on the root `workflow.run` span so every turn of a multi-turn session shares
|
|
28
|
+
* one id, letting a consumer group per-run traces back into their session.
|
|
29
|
+
*/
|
|
30
|
+
readonly SESSION_ID: "noetic.session.id";
|
|
31
|
+
/** Resource the session is scoped to (the run's `ctx.resourceId`), when set. */
|
|
32
|
+
readonly RESOURCE_ID: "noetic.resource.id";
|
|
25
33
|
};
|
|
@@ -25,4 +25,12 @@ export const NoeticAttr = {
|
|
|
25
25
|
WORKFLOW_EDGES: 'noetic.workflow.edges',
|
|
26
26
|
/** Id of the declared workflow node an `llm.call`/`tool.call` span belongs to. */
|
|
27
27
|
NODE_ID: 'noetic.node.id',
|
|
28
|
+
/**
|
|
29
|
+
* Conversation/session this run belongs to (the run's `ctx.threadId`). Stamped
|
|
30
|
+
* on the root `workflow.run` span so every turn of a multi-turn session shares
|
|
31
|
+
* one id, letting a consumer group per-run traces back into their session.
|
|
32
|
+
*/
|
|
33
|
+
SESSION_ID: 'noetic.session.id',
|
|
34
|
+
/** Resource the session is scoped to (the run's `ctx.resourceId`), when set. */
|
|
35
|
+
RESOURCE_ID: 'noetic.resource.id',
|
|
28
36
|
};
|
|
@@ -158,9 +158,12 @@ export async function parseAndRunWorkflow(opts) {
|
|
|
158
158
|
}
|
|
159
159
|
/**
|
|
160
160
|
* Open the root `workflow.run` span and stamp the static DAG onto it (document,
|
|
161
|
-
* version, node/edge graph)
|
|
162
|
-
* step's model/tool spans nest under
|
|
163
|
-
* declared workflow graph, with the
|
|
161
|
+
* version, node/edge graph) plus the session/resource the run belongs to. The
|
|
162
|
+
* span is installed on `ctx.span` so the LLM step's model/tool spans nest under
|
|
163
|
+
* it — the trace tree then mirrors the declared workflow graph, with the
|
|
164
|
+
* executed path overlaid (issue #50 follow-up). The session id (`ctx.threadId`)
|
|
165
|
+
* is shared by every turn of a conversation, so consumers can group the per-run
|
|
166
|
+
* traces of one session back together.
|
|
164
167
|
*/
|
|
165
168
|
function beginWorkflowRunSpan(harness, ctx, doc) {
|
|
166
169
|
const span = harness.createSpan('workflow.run', null);
|
|
@@ -170,6 +173,10 @@ function beginWorkflowRunSpan(harness, ctx, doc) {
|
|
|
170
173
|
span.setAttribute(NoeticAttr.WORKFLOW_NODE_COUNT, graph.nodes.length);
|
|
171
174
|
span.setAttribute(NoeticAttr.WORKFLOW_NODES, JSON.stringify(graph.nodes));
|
|
172
175
|
span.setAttribute(NoeticAttr.WORKFLOW_EDGES, JSON.stringify(graph.edges));
|
|
176
|
+
span.setAttribute(NoeticAttr.SESSION_ID, ctx.threadId);
|
|
177
|
+
if (ctx.resourceId !== undefined) {
|
|
178
|
+
span.setAttribute(NoeticAttr.RESOURCE_ID, ctx.resourceId);
|
|
179
|
+
}
|
|
173
180
|
installRunSpan(ctx, span);
|
|
174
181
|
return span;
|
|
175
182
|
}
|