Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 4f97215

Browse files
committed
Create the pipeline sensitive context when creating a pipeline instance, not on every processing
We used to create the pipeline context during pipeline processing which means we cannot reuse the same pipeline for output that spans several data buffers.
1 parent fbff397 commit 4f97215

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/codegate/pipeline/base.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,13 @@ def __init__(
277277
self.secret_manager = secret_manager
278278
self.is_fim = is_fim
279279
self.context = PipelineContext()
280+
281+
# we create the sesitive context here so that it is not shared between individual requests
282+
# TODO: could we get away with just generating the session ID for an instance?
283+
self.context.sensitive = PipelineSensitiveData(
284+
manager=self.secret_manager,
285+
session_id=str(uuid.uuid4()),
286+
)
280287
self.context.metadata["is_fim"] = is_fim
281288

282289
async def process_request(
@@ -290,17 +297,14 @@ async def process_request(
290297
is_copilot: bool = False,
291298
) -> PipelineResult:
292299
"""Process a request through all pipeline steps"""
293-
self.context.sensitive = PipelineSensitiveData(
294-
manager=self.secret_manager,
295-
session_id=str(uuid.uuid4()),
296-
api_key=api_key,
297-
model=model,
298-
provider=provider,
299-
api_base=api_base,
300-
)
301300
self.context.metadata["extra_headers"] = extra_headers
302301
current_request = request
303302

303+
self.context.sensitive.api_key = api_key
304+
self.context.sensitive.model = model
305+
self.context.sensitive.provider = provider
306+
self.context.sensitive.api_base = api_base
307+
304308
# For Copilot provider=openai. Use a flag to not clash with other places that may use that.
305309
provider_db = "copilot" if is_copilot else provider
306310

0 commit comments

Comments
 (0)