fix: upsert traces to handle duplicate IDs from intermediate flushes
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-Claude) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "agentlens-sdk",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.2",
|
||||
"description": "AgentLens TypeScript SDK — Agent observability that traces decisions, not just API calls.",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
|
||||
@@ -27,7 +27,12 @@ export class BatchTransport {
|
||||
}
|
||||
|
||||
add(trace: TracePayload): void {
|
||||
this.buffer.push(trace);
|
||||
const idx = this.buffer.findIndex((t) => t.id === trace.id);
|
||||
if (idx !== -1) {
|
||||
this.buffer[idx] = trace;
|
||||
} else {
|
||||
this.buffer.push(trace);
|
||||
}
|
||||
if (this.buffer.length >= this.maxBatchSize) {
|
||||
void this._doFlush();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user