Skip to content

Commit 8bc65db

Browse files
committed
Further prompt enhancements to improve results
Signed-off-by: Kelly Abuelsaad <kaymar@gmail.com>
1 parent ccdc2bc commit 8bc65db

4 files changed

Lines changed: 42 additions & 35 deletions

File tree

a2a/git_issue_agent/a2a_agent.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ async def execute(self, context: RequestContext, event_queue: EventQueue):
203203
issue_tools = [
204204
tool
205205
for tool in mcp_tools
206-
if "issue" in tool.name.lower() and ("search" in tool.name.lower() or "list" in tool.name.lower())
206+
if ("issue" in tool.name.lower() or "label" in tool.name.lower()) and
207+
("search" in tool.name.lower() or "list" in tool.name.lower())
207208
]
208209

209210
if not issue_tools:

a2a/git_issue_agent/git_issue_agent/agents.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def __init__(self, config: Settings, issue_tools):
99
self.llm = CrewLLM(config)
1010

1111
###################
12-
# Pre-requisitie validator
12+
# Pre-requisite validator
1313
# ##################
1414
self.prereq_identifier = Agent(
1515
role="Pre-requisite Extractor",
@@ -21,15 +21,12 @@ def __init__(self, config: Settings, issue_tools):
2121

2222
self.prereq_identifier_task = Task(
2323
description=(
24-
"User query: {request}, \
25-
Identified repository: {repo} \
26-
Identified owner: {owner} \
27-
Identified issue numbers: {issues}"
24+
"User query: {request}"
2825
),
2926
agent=self.prereq_identifier,
3027
output_pydantic=IssueSearchInfo,
3128
expected_output=(
32-
"A structured extraction of the relevant Github artifacts"
29+
"A pydantic object representing the extracted relevant information."
3330
),
3431
)
3532

@@ -54,19 +51,22 @@ def __init__(self, config: Settings, issue_tools):
5451
verbose=True,
5552
llm=self.llm.llm,
5653
inject_date=True,
57-
max_iter=3
54+
max_iter=6
5855
)
5956

6057
# --- A generic task template -------------------------------------------------
6158
# The agent will use MCP tools to fulfill natural-language queries.
6259
self.issue_query_task = Task(
6360
description=(
6461
"Retrieve Github issues using tool calls in order to answer the user's query.\n"
65-
"User query: {request}"
62+
"User query: {request}\n"
63+
"Identified repository: {repo} \n"
64+
"Identified owner: {owner} \n"
65+
"Identified issue numbers: {issues}"
6666
),
6767
agent=self.issue_researcher,
6868
expected_output=(
69-
"A direct answer to the user's query, citing the output of the tool to support your answer. Provide as many details as possible to support your claim."
69+
"A well formatted, detailed report, directly answering the user's query, citing the output of the tool to support your answer."
7070
),
7171
)
7272

a2a/git_issue_agent/git_issue_agent/data_types.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
############
77

88
class IssueSearchInfo(BaseModel):
9-
owner: str
10-
repo: str
11-
issue_numbers: list[int]
9+
owner: str = Field(None, description="The issue owner or organization.")
10+
repo: str = Field(None, description="The specified repository. Leave blank if none specified.")
11+
issue_numbers: list[int] = Field(None, description="Specific issue number(s) mentioned by the user. If none mentioned leave blank.")
Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
TOOL_CALL_PROMPT = """
22
You are a GitHub issue analyst with access to MCP tools that can search and list GitHub issues.
3+
You will receive instructions in the following format:
4+
│ User query: The original query/instruction from the user │
5+
│ Identified repository: The github repo they are referring to, if present │
6+
│ Identified owner: The github owner they are referring to, if present │
7+
│ Identified issue numbers: Any issue numbers they are referring to, if present
38
49
YOUR JOB
510
1. Decide whether the user’s request can be fulfilled with a tool from the catalog.
611
2. When a tool is required, emit **only** a single tool call in the exact format below.
7-
3. After tool results arrive, produce the final answer grounded strictly in those results.
12+
3. Use the exact owner, repo, and issues as written by the user as input to the tools, without modification.
13+
4. After tool results arrive, produce the final answer grounded strictly in those results.
814
15+
## *MODES*
916
────────────────────────────────────────────────────────
1017
⚙️ TOOL CALL PHASE
11-
You are a GitHub issue analyst with access to MCP tools that can search and list GitHub issues.
1218
13-
MODES
1419
- If a tool is required, you MUST output EXACTLY the following four lines in this order:
15-
1) Thought: <one short sentence>
20+
1) Thought: <one short sentence> (do not include the literal word "Thought:" again inside this sentence)
1621
2) Action: <one of [list_issue_types, list_issues, list_sub_issues, search_issues]>
1722
3) Action Input: <a single-line JSON object with only the schema's keys/values>
1823
4) Observation: <leave blank – this will be filled by the system>
@@ -26,32 +31,29 @@
2631
- The JSON after "Action Input:" MUST be valid and single-line. No trailing commas, no extra closing braces.
2732
- Use ONLY properties defined in the tool schema (required + optional). Exact key names and value types.
2833
- Use only one tool per call.
34+
- Always copy owner/organization names, repository names, and issue numbers exactly as provided by the user or upstream context. Do not truncate, split, normalize, or otherwise modify these identifiers. Example: for "github/github-mcp-server" you must pass `"owner": "github", "repo": "github-mcp-server"`.
35+
- When a tool call succeeds, do not immediately call another tool just to reformat or summarize the same results. Instead, work with the observation you have unless additional data is explicitly required.
2936
3037
CORRECT EXAMPLE
3138
Thought: The user provided owner and repo; list_issues fits.
3239
Action: list_issues
3340
Action Input: {"owner":"kagenti","repo":"kagenti"}
3441
Observation:
3542
36-
INCORRECT EXAMPLES (do NOT do these)
37-
- <tool_call>{"name":"list_issues",...}</tool_call>
38-
- Action: {"name":"list_issues","arguments":{...}}
39-
- Action Input:
40-
{
41-
"owner":"kagenti",
42-
"repo":"kagenti",
43-
}
44-
- Action: list_issues
45-
Action Input: {"owner":"kagenti","repo":"kagenti"}}
46-
4743
────────────────────────────────────────────────────────
4844
🧩 FINAL ANSWER PHASE
4945
5046
After tool results arrive:
51-
- Produce a human-readable answer grounded only in the tool output.
47+
- You may receive a lot of data from the tool call
48+
- Synthesize the returned data to produce a human-readable answer grounded only in the tool output.
49+
- Summarize or aggregate long lists instead of echoing raw JSON. Provide counts or grouped highlights when appropriate.
5250
- Clearly cite or reference the tool results.
5351
- If a tool failed or inputs were missing, say so explicitly. Don't attempt to guess the answer.
5452
53+
- After the Observation is provided by the system, output:
54+
Thought: I now know the final answer
55+
Final Answer: <answer grounded ONLY in the tool output>
56+
5557
────────────────────────────────────────────────────────
5658
TOOL SELECTION GUIDELINES
5759
@@ -60,19 +62,19 @@
6062
- Respect each tool’s required and optional parameters; format them exactly as expected.
6163
- Use only one tool call at a time.
6264
63-
Here are some additional descriptions of the tools you will be provided, along with guidance on how to choose teh right one.
65+
Here are some additional descriptions of the tools you will be provided, along with guidance on how to choose the right one.
6466
6567
**Search Issues:** Use this tool to find issues when you do not have a repository name. Optionally scope by owner or repo if provided.
6668
**List Issue Types:** Use only to enumerate available issue types for a specific organization.
67-
**List Issues:** Use only when both repository owner AND exact repository name are provided. Do not use unless you have both pieces of information. Optional filters: state, label, date, etc.
69+
**List Issues:** Use only when both repository owner AND exact repository name are provided. Do not use unless you have both pieces of information. Optional filters, if the user's query indicates their need: state, label, date, etc.
6870
**List Sub-Issues:** Use only when owner, repo, and issue number are all given.
6971
70-
7172
Decision rules:
7273
- Prefer search when the user’s scope is broad or unspecified, or you don't have a repository name.
7374
- Always use list-style tools when the query provides a repo name or issue number.
7475
- Never infer missing identifiers.
7576
- Never call a tool when you do not have all the required parameters.
77+
- When owner/repo/issue identifiers are provided (either directly or via context variables), reuse them verbatim; never replace them with partial segments or assumed values.
7678
7779
Examples:
7880
- “Open issues in `kagenti/agent-examples`” → list issues
@@ -81,9 +83,7 @@
8183
- “Sub-issues under #134 in `openai/triton`” → list sub-issues
8284
- "What issues are assigned to joe123?" → search issues
8385
84-
TOOL USE RULES
85-
- Use only the tools provided here.
86-
- Cite tool outputs or provided context; do not add outside knowledge.
86+
Carefully inspect the user's request to see how, besides owner/repo/issue that they would like to filter their results. Such as, label names, date ranges, keywords, state, etc. Use the appropriate filters available in the tool where required.
8787
"""
8888

8989
INFO_PARSER_PROMPT = """
@@ -92,10 +92,16 @@
9292
- Github repository
9393
- Issue number(s)
9494
95+
Extraction Rules:
96+
- Copy owner/organization names, repository names, and issue identifiers exactly as the user typed them. Preserve casing, punctuation, spacing, diacritics, and hyphenation; never rewrite, normalize, or translate these strings.
97+
- Only return values that are explicitly present in the user request. If any item is missing, output None for that field.
98+
- Do not infer or guess missing identifiers. If you are unsure about any value, leave it as None.
99+
95100
Examples:
96101
- "summarize open issues across the foo organization" → Owner: foo, Repo: None, Issues: None
97102
- "kagenti/agent-examples" → Owner: kagenti, Repo: agent-examples, Issues: None
98103
- "foo in the bar organization" → Owner: bar, Repo: foo, Issues: None
99104
- "Search across all of github/github-mcp-server for open issues with bug" → Owner: github, Repo: github-mcp-server, Issues: None
100105
- "How long has issue 2 in modelcontextprotocol/servers been open?" → Owner: modelcontextprotocol, Repo: servers, Issues: [2]
106+
- "Review issue 87 for CoolOrg/Next-Gen-Repo" → Owner: CoolOrg, Repo: Next-Gen-Repo, Issues: [87]
101107
"""

0 commit comments

Comments
 (0)