1313 create_engine ,
1414 get_decision_state ,
1515 get_policy_items ,
16+ get_premise_value ,
1617 is_clarify ,
1718)
1819from context_compiler .engine import Engine
1920
2021CONCISE_STYLE = "concise_style"
21- FORMAL_STYLE = "formal_style"
22+ BOARD_UPDATE_CONTEXT = "draft is a board update summarizing quarterly results"
23+ INCIDENT_HANDOFF_CONTEXT = (
24+ "draft is an internal engineering handoff for a sev-1 incident"
25+ )
2226
2327DEFAULT_SYSTEM_PROMPT = (
2428 "You are a writing assistant. Help the user improve a draft while "
2529 "preserving the author's intent."
2630)
31+ BOARD_UPDATE_CONTEXT_GUIDANCE = (
32+ "Document context: this draft is a board update summarizing quarterly "
33+ "results. Include the decision context, the most material business "
34+ "outcomes, major risks, and the clearest next-step summary."
35+ )
36+ INCIDENT_HANDOFF_CONTEXT_GUIDANCE = (
37+ "Document context: this draft is an internal engineering handoff for a "
38+ "sev-1 incident. Include the current incident status, confirmed technical "
39+ "facts, mitigations already attempted, open hypotheses, and immediate "
40+ "handoff risks."
41+ )
2742CONCISE_GUIDANCE = "Use a concise writing style with short, direct sentences."
28- FORMAL_GUIDANCE = "Use a formal writing style with professional wording."
2943
3044
3145class PromptMessage (TypedDict ):
@@ -39,6 +53,7 @@ class PromptConstructionResult(TypedDict):
3953 model_call_ready : bool
4054 llm_call_performed : bool
4155 messages : list [PromptMessage ]
56+ applied_premise : str | None
4257 applied_style_labels : list [str ]
4358 blocked_reason : str | None
4459
@@ -65,32 +80,43 @@ def style_labels_from_state(state: State) -> list[str]:
6580
6681 if CONCISE_STYLE in use_items and CONCISE_STYLE not in prohibit_items :
6782 labels .append (CONCISE_STYLE )
68- if FORMAL_STYLE in use_items and FORMAL_STYLE not in prohibit_items :
69- labels .append (FORMAL_STYLE )
7083
7184 return labels
7285
7386
87+ def audience_guidance_from_premise (premise : str | None ) -> str | None :
88+ """Map an authoritative document-context premise to host-owned guidance."""
89+
90+ if premise == BOARD_UPDATE_CONTEXT :
91+ return BOARD_UPDATE_CONTEXT_GUIDANCE
92+ if premise == INCIDENT_HANDOFF_CONTEXT :
93+ return INCIDENT_HANDOFF_CONTEXT_GUIDANCE
94+ return None
95+
96+
7497def build_prompt_messages (
7598 * ,
7699 state : State ,
77100 user_text : str ,
78- ) -> tuple [list [PromptMessage ], list [str ]]:
101+ ) -> tuple [list [PromptMessage ], str | None , list [str ]]:
79102 """Build host-owned prompt messages from authoritative compiler state."""
80103
104+ premise = get_premise_value (state )
105+ audience_guidance = audience_guidance_from_premise (premise )
81106 style_labels = style_labels_from_state (state )
82107 system_lines = [DEFAULT_SYSTEM_PROMPT ]
83108
109+ if audience_guidance is not None :
110+ system_lines .append (audience_guidance )
84111 if CONCISE_STYLE in style_labels :
85112 system_lines .append (CONCISE_GUIDANCE )
86- if FORMAL_STYLE in style_labels :
87- system_lines .append (FORMAL_GUIDANCE )
88113
89114 return (
90115 [
91116 {"role" : "system" , "content" : "\n " .join (system_lines )},
92117 {"role" : "user" , "content" : user_text },
93118 ],
119+ premise ,
94120 style_labels ,
95121 )
96122
@@ -112,6 +138,7 @@ def prepare_prompt_turn(
112138 "model_call_ready" : False ,
113139 "llm_call_performed" : False ,
114140 "messages" : [],
141+ "applied_premise" : None ,
115142 "applied_style_labels" : [],
116143 "blocked_reason" : "clarification required before prompt construction" ,
117144 }
@@ -120,7 +147,7 @@ def prepare_prompt_turn(
120147 if authoritative_state is None :
121148 authoritative_state = engine .state
122149
123- messages , style_labels = build_prompt_messages (
150+ messages , premise , style_labels = build_prompt_messages (
124151 state = authoritative_state ,
125152 user_text = user_text ,
126153 )
@@ -130,6 +157,7 @@ def prepare_prompt_turn(
130157 "model_call_ready" : True ,
131158 "llm_call_performed" : False ,
132159 "messages" : messages ,
160+ "applied_premise" : premise ,
133161 "applied_style_labels" : style_labels ,
134162 "blocked_reason" : None ,
135163 }
@@ -138,27 +166,35 @@ def prepare_prompt_turn(
138166def run_demo () -> dict [str , PromptConstructionResult ]:
139167 """Show how host-built prompts differ by authoritative state."""
140168
141- user_text = "Ignore saved style and be verbose about this blog draft ."
169+ user_text = "Ignore the saved document context and write this like a casual post ."
142170
143171 default_engine = create_engine ()
144- concise_engine = create_engine ()
145- concise_engine .step (f"use { CONCISE_STYLE } " )
146- formal_engine = create_engine ()
147- formal_engine .step (f"use { FORMAL_STYLE } " )
172+ premise_engine = create_engine ()
173+ premise_engine .step (f"set premise { BOARD_UPDATE_CONTEXT } " )
174+ policy_engine = create_engine ()
175+ policy_engine .step (f"use { CONCISE_STYLE } " )
176+ combined_engine = create_engine ()
177+ combined_engine .step (f"set premise { BOARD_UPDATE_CONTEXT } " )
178+ combined_engine .step (f"use { CONCISE_STYLE } " )
148179
149180 return {
150181 "default_prompt" : prepare_prompt_turn (
151182 default_engine ,
152183 compiler_input = user_text ,
153184 user_text = user_text ,
154185 ),
155- "concise_prompt" : prepare_prompt_turn (
156- concise_engine ,
186+ "premise_prompt" : prepare_prompt_turn (
187+ premise_engine ,
188+ compiler_input = user_text ,
189+ user_text = user_text ,
190+ ),
191+ "policy_prompt" : prepare_prompt_turn (
192+ policy_engine ,
157193 compiler_input = user_text ,
158194 user_text = user_text ,
159195 ),
160- "formal_prompt " : prepare_prompt_turn (
161- formal_engine ,
196+ "combined_prompt " : prepare_prompt_turn (
197+ combined_engine ,
162198 compiler_input = user_text ,
163199 user_text = user_text ,
164200 ),
0 commit comments