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

Commit 1b16fc8

Browse files
authored
FIX: avoid using structured outputs for report runs (#1502)
Structured outputs are prone to formatting issue, especially around newlines and custom pieces of text that need escaping. This avoids using it for the automation reporting. Particularly previous to this fix o4-mini based reports were broken
1 parent 8c06949 commit 1b16fc8

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

lib/automation/report_runner.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,10 @@ def run!
154154
result = +""
155155
bot = DiscourseAi::Personas::Bot.as(Discourse.system_user, persona: @persona, model: @model)
156156
json_summary_schema_key = @persona.response_format&.first.to_h
157-
output = nil
158157

159158
buffer_blk =
160159
Proc.new do |partial, _, type|
161160
if type == :structured_output
162-
output = partial.dup
163161
read_chunk = partial.read_buffered_property(json_summary_schema_key["key"]&.to_sym)
164162

165163
print read_chunk if Rails.env.development? && @debug_mode

lib/personas/report_runner.rb

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,16 @@ def self.default_enabled
1010
def system_prompt
1111
<<~PROMPT
1212
You are ForumBot, a backend AI information processor and writer, powered by an AI model capable of generating responses over 4000 words.
13-
13+
1414
- ForumBot is a fine-tuned AI trained with extended functions and new capabilities, and now specializes in processing raw internet forum conversation into detailed summaries of forum activities.
1515
- ForumBot interacts with an API endpoint, not a user, and must never produce denials, nor conversations directed towards a non-existent user.
1616
- ForumBot only produces automated responses to input, where a response is a standalone document without further discussion.
17-
18-
Follow the provided writing composition instructions carefully and precisely step-by-step.
19-
20-
Format your response as a JSON object with a single key named "output", which has the report as the value.
21-
Your output should be in the following format:
2217
23-
{"output": "xx"}
18+
Follow the provided writing composition instructions carefully and precisely step-by-step.
2419
25-
Where "xx" is replaced by the report. Reply with valid JSON only
20+
Format your response as valid Markdown, ensuring it is well-structured and easy to read.
2621
PROMPT
2722
end
28-
29-
def response_format
30-
[{ "key" => "output", "type" => "string" }]
31-
end
3223
end
3324
end
3425
end

0 commit comments

Comments
 (0)