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

Commit 0c09b9e

Browse files
committed
Create the pipeline sensitive context when creating a pipeline instance, not on every processing
1 parent 84d589a commit 0c09b9e

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
@@ -275,6 +275,13 @@ def __init__(
275275
self.secret_manager = secret_manager
276276
self.is_fim = is_fim
277277
self.context = PipelineContext()
278+
279+
# we create the sesitive context here so that it is not shared between individual requests
280+
# TODO: could we get away with just generating the session ID for an instance?
281+
self.context.sensitive = PipelineSensitiveData(
282+
manager=self.secret_manager,
283+
session_id=str(uuid.uuid4()),
284+
)
278285
self.context.metadata["is_fim"] = is_fim
279286

280287
async def process_request(
@@ -288,17 +295,14 @@ async def process_request(
288295
is_copilot: bool = False,
289296
) -> PipelineResult:
290297
"""Process a request through all pipeline steps"""
291-
self.context.sensitive = PipelineSensitiveData(
292-
manager=self.secret_manager,
293-
session_id=str(uuid.uuid4()),
294-
api_key=api_key,
295-
model=model,
296-
provider=provider,
297-
api_base=api_base,
298-
)
299298
self.context.metadata["extra_headers"] = extra_headers
300299
current_request = request
301300

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

0 commit comments

Comments
 (0)