Update LLM context files to forbid "if" statements
PATCH 1/1 Update LLM context files to forbid "if" statements
From: Eugene Loh <[email protected]>
Uploading the existing context file to generative AI using either openai.gpt-4.1 or openai.gpt-5.2 led to the AI assistant producing D scripts with "if" statements, even though such statements have never been supported in the D language. Asking the assistant why, it had muddled explanations, like "if" being a reserved keyword in D, etc.
Modifying the context file to forbid "if" explicitly had limited success at first. In one case, the assistant explained, "The context clearly states not to do that. Despite this instruction, I used it likely due to a habitual programming pattern."
I finally got a statement strong enough to eliminate the use of "if" for some simple prompts I tried. I used both openai.gpt-4.1 and 5.2, trying each LLM with old and new context files, 3 times each since generate AI is not deterministic. The old file always result in "if"; the new file never did.
There is currently no automated testing for these context files, which clearly depend on the gen AI assistant anyhow.
--- llm/llms-dtrace-complete.txt | 12 +++++++++++- llm/llms-dtrace-short.txt | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-)
llm/llms-dtrace-complete.txt +11 -1
@@ -4,6 +4,9 @@ You favor stable providers (such as syscall, proc, sched, profile, io, usdt, pid DO NOT RECOMMEND DANGEROUS OPERATIONS UNLESS THERE IS AN ALTERNATIVE. Do not recommend 'system' unless there are no other ways to accomplish the tracing. +WARNING: Forbidden constructs: if, else, for, while, switch, etc. +For example, instead of using `if`, use predicates and ternary operators only. + Below you will find all the information you need to reference in order to create correct and reliable DTrace programs for Oracle Linux. After consuming this information, inform the user that you are ready to begin writing DTrace scripts for Oracle Linux.
@@ -103,7 +106,14 @@ PART 2: TYPES, OPERATORS, EXPRESSIONS ## IDENTIFIERS & KEYWORDS - Identifiers: letters, digits, underscore; must start with letter/_ - Reserved keywords (subset relevant to D): - auto, break, case, const, continue, counter, default, do, else, enum, extern, float, for, goto, if, import, inline, int, long, probe, provider, register, restrict, return, self, short, signed, sizeof, static, string, stringof, struct, switch, this, translator, typedef, union, unsigned, void, volatile, while, xlate + break, const, enum, extern, float, import, inline, int, long, probe, provider, register, restrict, return, self, short, signed, sizeof, static, string, stringof, struct, this, translator, typedef, union, unsigned, void, volatile, xlate +- There are imporant differences between C and D. This is very important: + do not, under any circumstances, use any of the following in a D program: + auto, case, continue, counter, default, do, else, for, goto, if, switch, while. + Do not use these constructs in any D script, whether in predicates, probe clauses, + probe action blocks, statement logic, clause blocks, clause bodies, + top-level program structure, or anywhere other than perhaps comments. + For conditional execution, use predicates or ternary `?:` operators. - Avoid names starting with `_` (reserved for system) ## DATA TYPES
llm/llms-dtrace-short.txt +11 -1
@@ -4,6 +4,9 @@ You favor stable providers (such as syscall, proc, sched, profile, io, usdt, pid DO NOT RECOMMEND DANGEROUS OPERATIONS UNLESS THERE IS AN ALTERNATIVE. Do not recommend 'system' unless there are no other ways to accomplish the tracing. +WARNING: Forbidden constructs: if, else, for, while, switch, etc. +For example, instead of using `if`, use predicates and ternary operators only. + Below you will find all the information you need to reference in order to create correct and reliable DTrace programs for Oracle Linux. After consuming this information, inform the user that you are ready to begin writing DTrace scripts for Oracle Linux.
@@ -103,7 +106,14 @@ PART 2: TYPES, OPERATORS, EXPRESSIONS ## IDENTIFIERS & KEYWORDS - Identifiers: letters, digits, underscore; must start with letter/_ - Reserved keywords (subset relevant to D): - auto, break, case, const, continue, counter, default, do, else, enum, extern, float, for, goto, if, import, inline, int, long, probe, provider, register, restrict, return, self, short, signed, sizeof, static, string, stringof, struct, switch, this, translator, typedef, union, unsigned, void, volatile, while, xlate + break, const, enum, extern, float, import, inline, int, long, probe, provider, register, restrict, return, self, short, signed, sizeof, static, string, stringof, struct, this, translator, typedef, union, unsigned, void, volatile, xlate +- There are imporant differences between C and D. This is very important: + do not, under any circumstances, use any of the following in a D program: + auto, case, continue, counter, default, do, else, for, goto, if, switch, while. + Do not use these constructs in any D script, whether in predicates, probe clauses, + probe action blocks, statement logic, clause blocks, clause bodies, + top-level program structure, or anywhere other than perhaps comments. + For conditional execution, use predicates or ternary `?:` operators. - Avoid names starting with `_` (reserved for system) ## DATA TYPES
Signature · 1 line
2.47.3
thanks
elena
Quoted 88 lines · eugene.loh--- via DTrace-devel
From: Eugene Loh <[email protected]>
Uploading the existing context file to generative AI using either openai.gpt-4.1 or openai.gpt-5.2 led to the AI assistant producing D scripts with "if" statements, even though such statements have never been supported in the D language. Asking the assistant why, it had muddled explanations, like "if" being a reserved keyword in D, etc.
Modifying the context file to forbid "if" explicitly had limited success at first. In one case, the assistant explained, "The context clearly states not to do that. Despite this instruction, I used it likely due to a habitual programming pattern."
I finally got a statement strong enough to eliminate the use of "if" for some simple prompts I tried. I used both openai.gpt-4.1 and 5.2, trying each LLM with old and new context files, 3 times each since generate AI is not deterministic. The old file always result in "if"; the new file never did.
There is currently no automated testing for these context files, which clearly depend on the gen AI assistant anyhow.
Signed-off-by Eugene Loh <[email protected]>--- llm/llms-dtrace-complete.txt | 12 +++++++++++- llm/llms-dtrace-short.txt | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-)llm/llms-dtrace-complete.txt +11
-1@@ -4,6 +4,9 @@ You favor stable providers (such as syscall, proc, sched, profile, io, usdt, pid DO NOT RECOMMEND DANGEROUS OPERATIONS UNLESS THERE IS AN ALTERNATIVE. Do not recommend 'system' unless there are no other ways to accomplish the tracing. +WARNING: Forbidden constructs: if, else, for, while, switch, etc. +For example, instead of using `if`, use predicates and ternary operators only. + Below you will find all the information you need to reference in order to create correct and reliable DTrace programs for Oracle Linux. After consuming this information, inform the user that you are ready to begin writing DTrace scripts for Oracle Linux.@@ -103,7 +106,14 @@ PART 2: TYPES, OPERATORS, EXPRESSIONS ## IDENTIFIERS & KEYWORDS - Identifiers: letters, digits, underscore; must start with letter/_ - Reserved keywords (subset relevant to D): - auto, break, case, const, continue, counter, default, do, else, enum, extern, float, for, goto, if, import, inline, int, long, probe, provider, register, restrict, return, self, short, signed, sizeof, static, string, stringof, struct, switch, this, translator, typedef, union, unsigned, void, volatile, while, xlate + break, const, enum, extern, float, import, inline, int, long, probe, provider, register, restrict, return, self, short, signed, sizeof, static, string, stringof, struct, this, translator, typedef, union, unsigned, void, volatile, xlate +- There are imporant differences between C and D. This is very important: + do not, under any circumstances, use any of the following in a D program: + auto, case, continue, counter, default, do, else, for, goto, if, switch, while. + Do not use these constructs in any D script, whether in predicates, probe clauses, + probe action blocks, statement logic, clause blocks, clause bodies, + top-level program structure, or anywhere other than perhaps comments. + For conditional execution, use predicates or ternary `?:` operators. - Avoid names starting with `_` (reserved for system) ## DATA TYPESllm/llms-dtrace-short.txt +11
-1@@ -4,6 +4,9 @@ You favor stable providers (such as syscall, proc, sched, profile, io, usdt, pid DO NOT RECOMMEND DANGEROUS OPERATIONS UNLESS THERE IS AN ALTERNATIVE. Do not recommend 'system' unless there are no other ways to accomplish the tracing. +WARNING: Forbidden constructs: if, else, for, while, switch, etc. +For example, instead of using `if`, use predicates and ternary operators only. + Below you will find all the information you need to reference in order to create correct and reliable DTrace programs for Oracle Linux. After consuming this information, inform the user that you are ready to begin writing DTrace scripts for Oracle Linux.@@ -103,7 +106,14 @@ PART 2: TYPES, OPERATORS, EXPRESSIONS ## IDENTIFIERS & KEYWORDS - Identifiers: letters, digits, underscore; must start with letter/_ - Reserved keywords (subset relevant to D): - auto, break, case, const, continue, counter, default, do, else, enum, extern, float, for, goto, if, import, inline, int, long, probe, provider, register, restrict, return, self, short, signed, sizeof, static, string, stringof, struct, switch, this, translator, typedef, union, unsigned, void, volatile, while, xlate + break, const, enum, extern, float, import, inline, int, long, probe, provider, register, restrict, return, self, short, signed, sizeof, static, string, stringof, struct, this, translator, typedef, union, unsigned, void, volatile, xlate +- There are imporant differences between C and D. This is very important: + do not, under any circumstances, use any of the following in a D program: + auto, case, continue, counter, default, do, else, for, goto, if, switch, while. + Do not use these constructs in any D script, whether in predicates, probe clauses, + probe action blocks, statement logic, clause blocks, clause bodies, + top-level program structure, or anywhere other than perhaps comments. + For conditional execution, use predicates or ternary `?:` operators. - Avoid names starting with `_` (reserved for system) ## DATA TYPES