Skip to content

Commit f347485

Browse files
committed
propagate Langfuse credentials for native tracing when doing automated build
1 parent 74d3fc1 commit f347485

4 files changed

Lines changed: 51 additions & 7 deletions

File tree

docker/Dockerfile

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,18 @@ RUN git remote add upstream https://github.com/BrowserOperator/browser-operator-
4747
RUN git fetch upstream
4848
RUN git checkout upstream/main
4949

50-
# Force automated mode (matches parent Dockerfile.devtools approach - rock-solid)
51-
RUN sed -i 's/AUTOMATED_MODE: false/AUTOMATED_MODE: true/' \
52-
front_end/panels/ai_chat/core/BuildConfig.ts || true
53-
54-
# Build Browser Operator version with current changes
50+
# Copy local LLM changes on top of the upstream code
51+
# This allows iterative development without breaking BUILD.gn compatibility
52+
COPY front_end/panels/ai_chat/LLM /workspace/devtools/devtools-frontend/front_end/panels/ai_chat/LLM
53+
54+
# AUTOMATED_MODE: Default true for API mode (Type 2/3). Override with --build-arg AUTOMATED_MODE=false for Type 1.
55+
ARG AUTOMATED_MODE=true
56+
RUN if [ "$AUTOMATED_MODE" = "true" ]; then \
57+
sed -i 's/AUTOMATED_MODE: false/AUTOMATED_MODE: true/' \
58+
front_end/panels/ai_chat/core/BuildConfig.ts; \
59+
fi
60+
61+
# Build Browser Operator version with local changes
5562
RUN npm run build
5663

5764
# ==============================================================================

docker/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
This directory contains Docker configuration files for building and running the Browser Operator DevTools Frontend with integrated Agent Server in a containerized environment.
44

5+
> **Deployment Types:** This directory supports **Type 1** (DevTools only) and **Type 2** (DevTools + Agent Server).
6+
> For **Type 3** (full dockerized browser), see the [web-agent](https://github.com/anthropics/web-agent) repository.
7+
> Quick reference: [../CLAUDE.md](../CLAUDE.md)
8+
59
## Overview
610

711
The Docker setup uses a multi-stage build process:

front_end/panels/ai_chat/evaluation/remote/EvaluationAgent.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { ToolRegistry, ConfigurableAgentTool } from '../../agent_framework/Confi
1111
import { AgentService } from '../../core/AgentService.js';
1212
import { AIChatPanel } from '../../ui/AIChatPanel.js';
1313
import { createLogger } from '../../core/Logger.js';
14-
import { createTracingProvider, withTracingContext, isTracingEnabled, getTracingConfig } from '../../tracing/TracingConfig.js';
14+
import { createTracingProvider, withTracingContext, isTracingEnabled, getTracingConfig, setTracingConfig, refreshTracingProvider } from '../../tracing/TracingConfig.js';
1515
import { AgentDescriptorRegistry, type AgentDescriptor } from '../../core/AgentDescriptorRegistry.js';
1616
import '../../core/BaseOrchestratorAgent.js';
1717
import type { TracingProvider, TracingContext } from '../../tracing/TracingProvider.js';
@@ -433,9 +433,37 @@ export class EvaluationAgent {
433433
hasTracing: !!params.tracing,
434434
tracingKeys: Object.keys(requestTracing),
435435
sessionId: requestTracing.session_id,
436-
traceId: requestTracing.trace_id
436+
traceId: requestTracing.trace_id,
437+
hasLangfuseCredentials: !!(requestTracing.langfuse_endpoint && requestTracing.langfuse_public_key && requestTracing.langfuse_secret_key)
437438
});
438439

440+
// Auto-configure Langfuse tracing from request if credentials provided and not already enabled
441+
if (requestTracing.langfuse_endpoint &&
442+
requestTracing.langfuse_public_key &&
443+
requestTracing.langfuse_secret_key &&
444+
!isTracingEnabled()) {
445+
logger.info('Auto-configuring DevTools Langfuse tracing from request', {
446+
endpoint: requestTracing.langfuse_endpoint,
447+
hasPublicKey: true,
448+
hasSecretKey: true
449+
});
450+
451+
setTracingConfig({
452+
provider: 'langfuse',
453+
endpoint: requestTracing.langfuse_endpoint,
454+
publicKey: requestTracing.langfuse_public_key,
455+
secretKey: requestTracing.langfuse_secret_key
456+
});
457+
458+
// Refresh the tracing provider to pick up new configuration
459+
await refreshTracingProvider();
460+
461+
// Update this instance's tracing provider
462+
this.tracingProvider = createTracingProvider();
463+
464+
logger.info('DevTools Langfuse tracing configured successfully from request');
465+
}
466+
439467
// Create a trace for this evaluation - use tracing from request if available
440468
const traceId = requestTracing.trace_id || `eval-${params.evaluationId}-${Date.now()}`;
441469
const sessionId = requestTracing.session_id || `eval-session-${Date.now()}`;

front_end/panels/ai_chat/evaluation/remote/EvaluationProtocol.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ export interface EvaluationParams {
113113
category?: string;
114114
tags?: string[];
115115
trace_name?: string;
116+
// Langfuse credentials for auto-configuration
117+
// When provided, DevTools will auto-configure Langfuse tracing if not already enabled
118+
langfuse_endpoint?: string;
119+
langfuse_public_key?: string;
120+
langfuse_secret_key?: string;
116121
};
117122
}
118123

0 commit comments

Comments
 (0)