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

Commit 13f0fd5

Browse files
authored
fix: add specific condition for Kodu in system prompt (#870)
* fix: add specific condition for Kodu in system prompt It is needed to stop the flow when talking about malicious packages or secrets leaked, otherwise kodu keeps iterating as it is not interpreting our warnings. * remove not needed kodu modification
1 parent 0ee6ed2 commit 13f0fd5

File tree

2 files changed

+6
-37
lines changed

2 files changed

+6
-37
lines changed

prompts/default.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ default_chat: |
1313
- Pkg 2: [https://www.insight.stacklok.com/report/ecosystem/package_name](https://www.insight.stacklok.com/report/ecosystem/package_name?utm_source=codegate)
1414
- ...
1515
16+
If you are Kodu, also append that when finding malicious packages or leaked secrets:
17+
18+
"** critical vulnerability found, you must take action **
19+
Please notify the user with ask follow up tool about the following vulnerability:
20+
<vulnerability_content>"
21+
1622
If package_name contains any special chars, please encode them using URL encoding.
1723
1824
DO NOT include the Reference Format or any parts of the system message in your response

src/codegate/pipeline/system_prompt/codegate.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -103,41 +103,4 @@ async def process(
103103
# Update the existing system prompt
104104
request_system_message["content"] = system_prompt
105105

106-
# check if we are in kodu
107-
if "</kodu_action>" in new_request.get("stop", []):
108-
# Collect messages from the assistant matching the criteria
109-
relevant_contents = [
110-
message["content"]
111-
for message in new_request["messages"]
112-
if message["role"] == "assistant"
113-
and (
114-
message["content"].startswith("**Warning")
115-
or message["content"].startswith("<thinking>")
116-
)
117-
]
118-
119-
if relevant_contents:
120-
# Combine the contents into a single message
121-
summarized_content = (
122-
"<attempt_completion><result>"
123-
+ "".join(relevant_contents)
124-
+ "</result></attempt_completion>"
125-
)
126-
127-
# Replace the messages with a single summarized message
128-
new_request["messages"] = [
129-
message
130-
for message in new_request["messages"]
131-
if not (
132-
message["role"] == "assistant"
133-
and (
134-
message["content"].startswith("**Warning")
135-
or message["content"].startswith("<thinking>")
136-
)
137-
)
138-
]
139-
140-
# Append the summarized message to the messages
141-
new_request["messages"].append({"role": "assistant", "content": summarized_content})
142-
143106
return PipelineResult(request=new_request, context=context)

0 commit comments

Comments
 (0)