1818
1919from ._eval import evaluate_config
2020from ._sse import SSEParser
21+ from .version import VERSION
2122from .errors import (
2223 AuthenticationError ,
2324 ClientClosedError ,
3435# Sentinel value for detecting when no default was provided
3536_MISSING : Any = object ()
3637
38+ # Default agent identifier
39+ DEFAULT_AGENT = f"replane-python/{ VERSION } "
40+
3741logger = logging .getLogger ("replane" )
3842
3943
@@ -85,6 +89,7 @@ def __init__(
8589 initialization_timeout_ms : int = 5000 ,
8690 retry_delay_ms : int = 200 ,
8791 inactivity_timeout_ms : int = 30000 ,
92+ agent : str | None = None ,
8893 debug : bool = False ,
8994 ) -> None :
9095 """Initialize the Replane client.
@@ -99,6 +104,7 @@ def __init__(
99104 initialization_timeout_ms: Timeout for initial connection.
100105 retry_delay_ms: Initial delay between retries.
101106 inactivity_timeout_ms: Max time without SSE events before reconnect.
107+ agent: Agent identifier sent in X-Replane-Agent header. Defaults to SDK identifier.
102108 debug: Enable debug logging to see all client activity.
103109 """
104110 # Configure debug logging
@@ -130,6 +136,7 @@ def __init__(
130136 self ._init_timeout = initialization_timeout_ms / 1000.0
131137 self ._retry_delay = retry_delay_ms / 1000.0
132138 self ._inactivity_timeout = inactivity_timeout_ms / 1000.0
139+ self ._agent = agent or DEFAULT_AGENT
133140
134141 # Config storage
135142 self ._configs : dict [str , Config ] = {}
@@ -400,6 +407,7 @@ def _connect_stream(self) -> None:
400407 "Content-Type" : "application/json" ,
401408 "Accept" : "text/event-stream" ,
402409 "Cache-Control" : "no-cache" ,
410+ "X-Replane-Agent" : self ._agent ,
403411 }
404412
405413 logger .debug ("Sending POST request to %s" , path )
0 commit comments