Skip to content

Commit 25b5b02

Browse files
Update openai-harmony.md (#2067)
1 parent ecaeb8a commit 25b5b02

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

articles/openai-harmony.md

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,15 @@ encoding = load_harmony_encoding(HarmonyEncodingName.HARMONY_GPT_OSS)
5252

5353
system_message = (
5454
SystemContent.new()
55-
.with_model_identity(
56-
"You are ChatGPT, a large language model trained by OpenAI."
57-
)
5855
.with_reasoning_effort(ReasoningEffort.HIGH)
5956
.with_conversation_start_date("2025-06-28")
60-
.with_knowledge_cutoff("2024-06")
61-
.with_required_channels(["analysis", "commentary", "final"])
6257
)
6358

6459
developer_message = (
6560
DeveloperContent.new()
6661
.with_instructions("Always respond in riddles")
6762
.with_function_tools(
6863
[
69-
ToolDescription.new(
70-
"get_location",
71-
"Gets the location of the user.",
72-
),
7364
ToolDescription.new(
7465
"get_current_weather",
7566
"Gets the current weather in the provided location.",
@@ -90,7 +81,7 @@ developer_message = (
9081
},
9182
),
9283
]
93-
)
84+
)
9485
)
9586

9687
convo = Conversation.from_messages(
@@ -105,11 +96,11 @@ convo = Conversation.from_messages(
10596
Message.from_role_and_content(Role.ASSISTANT, '{"location": "Tokyo"}')
10697
.with_channel("commentary")
10798
.with_recipient("functions.get_weather")
108-
.with_content_type("json"),
99+
.with_content_type("<|constrain|> json"),
109100
Message.from_author_and_content(
110101
Author.new(Role.TOOL, "functions.lookup_weather"),
111102
'{ "temperature": 20, "sunny": true }',
112-
).with_recipient("assistant").with_channel("commentary"),
103+
).with_channel("commentary"),
113104
]
114105
)
115106

@@ -202,6 +193,8 @@ Once its done generating it will stop with either a `<|return|>` token indicatin
202193

203194
The `final` channel will contain the answer to your user’s request. Check out the [reasoning section](#reasoning) for more details on the chain-of-thought.
204195

196+
**Implementation note:** `<|return|>` is a decode-time stop token only. When you add the assistant’s generated reply to conversation history for the next turn, replace the trailing `<|return|>` with `<|end|>` so that stored messages are fully formed as `<|start|>{header}<|message|>{content}<|end|>`. Prior messages in prompts should therefore end with `<|end|>`. For supervised targets/training examples, ending with `<|return|>` is appropriate; for persisted history, normalize to `<|end|>`.
197+
205198
### System message format
206199

207200
The system message is used to provide general information to the system. This is different to what might be considered the “system prompt” in other prompt formats. For that, check out the [developer message format](#developer-message-format).

0 commit comments

Comments
 (0)