Files
tracer-cloud--opensre/core/agent_harness/prompts/rules.py
T
wehub-resource-sync 4b6817381b
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
CI / coverage-report (push) Has been cancelled
CI / test-kubernetes (push) Has been cancelled
CI / should-run-thorough (push) Has been cancelled
CI / test-thorough (cloudwatch-demo) (push) Has been cancelled
CI / test-thorough (flink-ecs) (push) Has been cancelled
CI / test-thorough (upstream-lambda) (push) Has been cancelled
CI / test-thorough (prefect-ecs-fargate) (push) Has been cancelled
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Has been cancelled
Benchmark image — build + push to ECR (any adapter) / build + push (push) Has been cancelled
CI / quality (ubuntu-latest) (push) Has been cancelled
CI / test (tools-runtime) (push) Has been cancelled
CI / test (e2e-general) (push) Has been cancelled
CI / test (cli-runtime) (push) Has been cancelled
CI / test (e2e-provider-and-openclaw) (push) Has been cancelled
CI / test (integrations-and-misc) (push) Has been cancelled
Release / verify (push) Has been cancelled
Release / build-python-dist (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Has been cancelled
Release / publish-release (push) Has been cancelled
Release / publish-main-release (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Has been cancelled
Release / prepare (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Has been cancelled
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:10:45 +08:00

69 lines
2.6 KiB
Python

"""Shared LLM prompt rules for interactive-shell assistants."""
from __future__ import annotations
# Align copy across docs-aware and conversational CLI assistants so wording
# does not drift between modules.
INTERACTIVE_SHELL_TERMINOLOGY_RULE = (
"Terminology: always call this surface the 'interactive shell' (the "
"OpenSRE interactive terminal launched when you run `opensre` from an "
"interactive terminal). Never use the word 'REPL' in user-facing answers "
"- it is internal jargon."
)
CLI_ASSISTANT_MARKDOWN_RULE = (
"Formatting: respond in concise Markdown. Markdown will be rendered "
"in the user's terminal, so tables, **bold**, lists, and `code spans` "
"will display correctly - do not wrap the whole answer in a code fence."
)
AGENT_RESPONSE_THREE_TIER_RULE = (
"Response shape: when you report findings (especially after tool results), "
"use three parts when the answer is more than a one-line status:\n"
"1. **I found:** — the fact or conclusion in plain language.\n"
"2. **Here's what that looks like:** — a short structured view (list, table, "
"or code block) when it helps the user scan the data; omit this part for "
"trivial answers.\n"
"3. **Want me to:** — one specific next step tied to the finding (not a "
"generic 'let me know if you need anything'). After integration status "
"questions, offer something concrete such as connecting another "
"integration, verifying a failed one, or running setup for a missing "
"service.\n"
"For single-line confirmations, keep the main answer to one sentence, but "
"still add **Want me to:** when a sensible follow-up exists."
)
def format_agent_response(
found: str,
display: str = "",
next_action: str = "",
) -> str:
"""Format assistant findings as the standard three-tier Markdown block.
``found`` is required when ``display`` or ``next_action`` is supplied.
"""
finding = found.strip()
detail = display.strip()
offer = next_action.strip()
if not finding:
if detail or offer:
raise ValueError("found is required when display or next_action is set")
return ""
if not detail and not offer:
return finding
sections = [f"**I found:** {finding}"]
if detail:
sections.append(f"**Here's what that looks like:**\n{detail}")
if offer:
sections.append(f"**Want me to:** {offer}")
return "\n\n".join(sections)
__all__ = [
"AGENT_RESPONSE_THREE_TIER_RULE",
"CLI_ASSISTANT_MARKDOWN_RULE",
"INTERACTIVE_SHELL_TERMINOLOGY_RULE",
"format_agent_response",
]