langsmith 0.5.13 → 0.5.14
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.
- package/dist/experimental/anthropic/context.cjs +23 -15
- package/dist/experimental/anthropic/context.js +23 -15
- package/dist/experimental/anthropic/messages.cjs +1 -1
- package/dist/experimental/anthropic/messages.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
|
@@ -57,7 +57,7 @@ class StreamManager {
|
|
|
57
57
|
return;
|
|
58
58
|
if (message.type === "result") {
|
|
59
59
|
if (message.modelUsage) {
|
|
60
|
-
(0, usage_js_1.correctUsageFromResults)(message.modelUsage, Object.values(this.assistant));
|
|
60
|
+
(0, usage_js_1.correctUsageFromResults)(message.modelUsage, Object.values(this.assistant).filter((runTree) => runTree != null));
|
|
61
61
|
}
|
|
62
62
|
const usage = message.modelUsage
|
|
63
63
|
? (0, usage_js_1.aggregateUsageFromModelUsage)(message.modelUsage)
|
|
@@ -100,6 +100,8 @@ class StreamManager {
|
|
|
100
100
|
},
|
|
101
101
|
outputs: { output: { messages: [] } },
|
|
102
102
|
});
|
|
103
|
+
if (this.assistant[messageId] == null)
|
|
104
|
+
return;
|
|
103
105
|
this.assistant[messageId].outputs = (() => {
|
|
104
106
|
const prevMessages = this.assistant[messageId].outputs?.output.messages ?? [];
|
|
105
107
|
const newMessages = (0, messages_js_1.convertFromAnthropicMessage)([message]);
|
|
@@ -125,22 +127,24 @@ class StreamManager {
|
|
|
125
127
|
? block.input.description.split(" ")[0]
|
|
126
128
|
: null) ||
|
|
127
129
|
"unknown-agent";
|
|
128
|
-
this.tools[block.id] ??=
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
this.tools[block.id] ??=
|
|
131
|
+
this.createChild("root", {
|
|
132
|
+
name,
|
|
133
|
+
run_type: "chain",
|
|
134
|
+
inputs: block.input,
|
|
135
|
+
start_time: eventTime,
|
|
136
|
+
}) ?? this.tools[block.id];
|
|
134
137
|
this.namespaces[block.id] ??= this.tools[block.id];
|
|
135
138
|
}
|
|
136
139
|
else {
|
|
137
140
|
const name = block.name || "unknown-tool";
|
|
138
|
-
this.tools[block.id] ??=
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
this.tools[block.id] ??=
|
|
142
|
+
this.createChild(namespace, {
|
|
143
|
+
name,
|
|
144
|
+
run_type: "tool",
|
|
145
|
+
inputs: block.input ? { input: block.input } : {},
|
|
146
|
+
start_time: eventTime,
|
|
147
|
+
}) ?? this.tools[block.id];
|
|
144
148
|
}
|
|
145
149
|
}
|
|
146
150
|
}
|
|
@@ -174,14 +178,16 @@ class StreamManager {
|
|
|
174
178
|
const toolError = "is_error" in block && block.is_error === true
|
|
175
179
|
? getToolError(result)
|
|
176
180
|
: undefined;
|
|
177
|
-
void this.tools[block.tool_use_id]
|
|
181
|
+
void this.tools[block.tool_use_id]?.end(toolOutput, toolError);
|
|
178
182
|
}
|
|
179
183
|
}
|
|
180
184
|
}
|
|
181
185
|
this.history[namespace].push(message);
|
|
182
186
|
}
|
|
183
187
|
createChild(namespace, args) {
|
|
184
|
-
const runTree = this.namespaces[namespace]
|
|
188
|
+
const runTree = this.namespaces[namespace]?.createChild(args);
|
|
189
|
+
if (runTree == null)
|
|
190
|
+
return undefined;
|
|
185
191
|
this.postRunQueue.push(runTree.postRun());
|
|
186
192
|
this.runTrees.push(runTree);
|
|
187
193
|
return runTree;
|
|
@@ -189,6 +195,8 @@ class StreamManager {
|
|
|
189
195
|
async finish() {
|
|
190
196
|
// Clean up incomplete tools and subagent calls
|
|
191
197
|
for (const tool of Object.values(this.tools)) {
|
|
198
|
+
if (tool == null)
|
|
199
|
+
continue;
|
|
192
200
|
if (tool.outputs == null && tool.error == null) {
|
|
193
201
|
void tool.end(undefined, "Run not completed (conversation ended)");
|
|
194
202
|
}
|
|
@@ -54,7 +54,7 @@ export class StreamManager {
|
|
|
54
54
|
return;
|
|
55
55
|
if (message.type === "result") {
|
|
56
56
|
if (message.modelUsage) {
|
|
57
|
-
correctUsageFromResults(message.modelUsage, Object.values(this.assistant));
|
|
57
|
+
correctUsageFromResults(message.modelUsage, Object.values(this.assistant).filter((runTree) => runTree != null));
|
|
58
58
|
}
|
|
59
59
|
const usage = message.modelUsage
|
|
60
60
|
? aggregateUsageFromModelUsage(message.modelUsage)
|
|
@@ -97,6 +97,8 @@ export class StreamManager {
|
|
|
97
97
|
},
|
|
98
98
|
outputs: { output: { messages: [] } },
|
|
99
99
|
});
|
|
100
|
+
if (this.assistant[messageId] == null)
|
|
101
|
+
return;
|
|
100
102
|
this.assistant[messageId].outputs = (() => {
|
|
101
103
|
const prevMessages = this.assistant[messageId].outputs?.output.messages ?? [];
|
|
102
104
|
const newMessages = convertFromAnthropicMessage([message]);
|
|
@@ -122,22 +124,24 @@ export class StreamManager {
|
|
|
122
124
|
? block.input.description.split(" ")[0]
|
|
123
125
|
: null) ||
|
|
124
126
|
"unknown-agent";
|
|
125
|
-
this.tools[block.id] ??=
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
this.tools[block.id] ??=
|
|
128
|
+
this.createChild("root", {
|
|
129
|
+
name,
|
|
130
|
+
run_type: "chain",
|
|
131
|
+
inputs: block.input,
|
|
132
|
+
start_time: eventTime,
|
|
133
|
+
}) ?? this.tools[block.id];
|
|
131
134
|
this.namespaces[block.id] ??= this.tools[block.id];
|
|
132
135
|
}
|
|
133
136
|
else {
|
|
134
137
|
const name = block.name || "unknown-tool";
|
|
135
|
-
this.tools[block.id] ??=
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
this.tools[block.id] ??=
|
|
139
|
+
this.createChild(namespace, {
|
|
140
|
+
name,
|
|
141
|
+
run_type: "tool",
|
|
142
|
+
inputs: block.input ? { input: block.input } : {},
|
|
143
|
+
start_time: eventTime,
|
|
144
|
+
}) ?? this.tools[block.id];
|
|
141
145
|
}
|
|
142
146
|
}
|
|
143
147
|
}
|
|
@@ -171,14 +175,16 @@ export class StreamManager {
|
|
|
171
175
|
const toolError = "is_error" in block && block.is_error === true
|
|
172
176
|
? getToolError(result)
|
|
173
177
|
: undefined;
|
|
174
|
-
void this.tools[block.tool_use_id]
|
|
178
|
+
void this.tools[block.tool_use_id]?.end(toolOutput, toolError);
|
|
175
179
|
}
|
|
176
180
|
}
|
|
177
181
|
}
|
|
178
182
|
this.history[namespace].push(message);
|
|
179
183
|
}
|
|
180
184
|
createChild(namespace, args) {
|
|
181
|
-
const runTree = this.namespaces[namespace]
|
|
185
|
+
const runTree = this.namespaces[namespace]?.createChild(args);
|
|
186
|
+
if (runTree == null)
|
|
187
|
+
return undefined;
|
|
182
188
|
this.postRunQueue.push(runTree.postRun());
|
|
183
189
|
this.runTrees.push(runTree);
|
|
184
190
|
return runTree;
|
|
@@ -186,6 +192,8 @@ export class StreamManager {
|
|
|
186
192
|
async finish() {
|
|
187
193
|
// Clean up incomplete tools and subagent calls
|
|
188
194
|
for (const tool of Object.values(this.tools)) {
|
|
195
|
+
if (tool == null)
|
|
196
|
+
continue;
|
|
189
197
|
if (tool.outputs == null && tool.error == null) {
|
|
190
198
|
void tool.end(undefined, "Run not completed (conversation ended)");
|
|
191
199
|
}
|
|
@@ -89,7 +89,7 @@ function isToolResultBlock(block) {
|
|
|
89
89
|
* @internal
|
|
90
90
|
*/
|
|
91
91
|
function isTaskTool(tool) {
|
|
92
|
-
return tool.type === "tool_use" && tool.name === "Task";
|
|
92
|
+
return (tool.type === "tool_use" && (tool.name === "Task" || tool.name === "Agent"));
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
95
|
* Type-assertion to check for tool blocks
|
|
@@ -83,7 +83,7 @@ function isToolResultBlock(block) {
|
|
|
83
83
|
* @internal
|
|
84
84
|
*/
|
|
85
85
|
export function isTaskTool(tool) {
|
|
86
|
-
return tool.type === "tool_use" && tool.name === "Task";
|
|
86
|
+
return (tool.type === "tool_use" && (tool.name === "Task" || tool.name === "Agent"));
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
89
|
* Type-assertion to check for tool blocks
|
package/dist/index.cjs
CHANGED
|
@@ -18,4 +18,4 @@ Object.defineProperty(exports, "PromptCache", { enumerable: true, get: function
|
|
|
18
18
|
Object.defineProperty(exports, "configureGlobalPromptCache", { enumerable: true, get: function () { return index_js_1.configureGlobalPromptCache; } });
|
|
19
19
|
Object.defineProperty(exports, "promptCacheSingleton", { enumerable: true, get: function () { return index_js_1.promptCacheSingleton; } });
|
|
20
20
|
// Update using yarn bump-version
|
|
21
|
-
exports.__version__ = "0.5.
|
|
21
|
+
exports.__version__ = "0.5.14";
|
package/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export { overrideFetchImplementation } from "./singletons/fetch.js";
|
|
|
5
5
|
export { getDefaultProjectName } from "./utils/project.js";
|
|
6
6
|
export { uuid7, uuid7FromTime } from "./uuid.js";
|
|
7
7
|
export { Cache, PromptCache, type CacheConfig, type CacheMetrics, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
|
|
8
|
-
export declare const __version__ = "0.5.
|
|
8
|
+
export declare const __version__ = "0.5.14";
|
package/dist/index.js
CHANGED
|
@@ -5,4 +5,4 @@ export { getDefaultProjectName } from "./utils/project.js";
|
|
|
5
5
|
export { uuid7, uuid7FromTime } from "./uuid.js";
|
|
6
6
|
export { Cache, PromptCache, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
|
|
7
7
|
// Update using yarn bump-version
|
|
8
|
-
export const __version__ = "0.5.
|
|
8
|
+
export const __version__ = "0.5.14";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "langsmith",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.14",
|
|
4
4
|
"description": "Client library to connect to the LangSmith Observability and Evaluation Platform.",
|
|
5
5
|
"packageManager": "yarn@1.22.19",
|
|
6
6
|
"files": [
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
"@ai-sdk/anthropic": "^3.0.0",
|
|
157
157
|
"@ai-sdk/openai": "^3.0.0",
|
|
158
158
|
"@ai-sdk/provider": "^3.0.0",
|
|
159
|
-
"@anthropic-ai/claude-agent-sdk": "^0.2.
|
|
159
|
+
"@anthropic-ai/claude-agent-sdk": "^0.2.83",
|
|
160
160
|
"@anthropic-ai/sdk": "^0.78.0",
|
|
161
161
|
"@babel/preset-env": "^7.22.4",
|
|
162
162
|
"@faker-js/faker": "^8.4.1",
|