agent-starter-pack 0.5.2__py3-none-any.whl → 0.6.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. {agent_starter_pack-0.5.2.dist-info → agent_starter_pack-0.6.0.dist-info}/METADATA +2 -2
  2. {agent_starter_pack-0.5.2.dist-info → agent_starter_pack-0.6.0.dist-info}/RECORD +66 -40
  3. agents/adk_base/notebooks/adk_app_testing.ipynb +1 -1
  4. agents/adk_base/template/.templateconfig.yaml +1 -1
  5. agents/adk_gemini_fullstack/README.md +148 -0
  6. agents/adk_gemini_fullstack/app/agent.py +349 -0
  7. agents/adk_gemini_fullstack/app/config.py +11 -0
  8. agents/adk_gemini_fullstack/notebooks/adk_app_testing.ipynb +353 -0
  9. agents/adk_gemini_fullstack/notebooks/evaluating_adk_agent.ipynb +1528 -0
  10. agents/adk_gemini_fullstack/template/.templateconfig.yaml +37 -0
  11. agents/adk_gemini_fullstack/tests/integration/test_agent.py +58 -0
  12. agents/agentic_rag/notebooks/adk_app_testing.ipynb +1 -1
  13. agents/agentic_rag/template/.templateconfig.yaml +1 -1
  14. agents/crewai_coding_crew/template/.templateconfig.yaml +1 -1
  15. agents/langgraph_base_react/template/.templateconfig.yaml +1 -1
  16. src/base_template/Makefile +21 -2
  17. src/base_template/README.md +8 -3
  18. src/base_template/pyproject.toml +1 -4
  19. src/cli/commands/create.py +17 -10
  20. src/cli/utils/template.py +13 -10
  21. src/data_ingestion/data_ingestion_pipeline/components/process_data.py +1 -1
  22. src/deployment_targets/agent_engine/app/agent_engine_app.py +17 -5
  23. src/deployment_targets/cloud_run/app/server.py +17 -2
  24. src/deployment_targets/cloud_run/tests/integration/test_server_e2e.py +1 -1
  25. src/deployment_targets/cloud_run/tests/load_test/.results/.placeholder +321 -0
  26. src/frontends/adk_gemini_fullstack/frontend/components.json +21 -0
  27. src/frontends/adk_gemini_fullstack/frontend/eslint.config.js +28 -0
  28. src/frontends/adk_gemini_fullstack/frontend/index.html +12 -0
  29. src/frontends/adk_gemini_fullstack/frontend/package-lock.json +5829 -0
  30. src/frontends/adk_gemini_fullstack/frontend/package.json +46 -0
  31. src/frontends/adk_gemini_fullstack/frontend/public/vite.svg +1 -0
  32. src/frontends/adk_gemini_fullstack/frontend/src/App.tsx +565 -0
  33. src/frontends/adk_gemini_fullstack/frontend/src/components/ActivityTimeline.tsx +244 -0
  34. src/frontends/adk_gemini_fullstack/frontend/src/components/ChatMessagesView.tsx +419 -0
  35. src/frontends/adk_gemini_fullstack/frontend/src/components/InputForm.tsx +60 -0
  36. src/frontends/adk_gemini_fullstack/frontend/src/components/WelcomeScreen.tsx +56 -0
  37. src/frontends/adk_gemini_fullstack/frontend/src/components/ui/badge.tsx +46 -0
  38. src/frontends/adk_gemini_fullstack/frontend/src/components/ui/button.tsx +59 -0
  39. src/frontends/adk_gemini_fullstack/frontend/src/components/ui/card.tsx +92 -0
  40. src/frontends/adk_gemini_fullstack/frontend/src/components/ui/input.tsx +21 -0
  41. src/frontends/adk_gemini_fullstack/frontend/src/components/ui/scroll-area.tsx +56 -0
  42. src/frontends/adk_gemini_fullstack/frontend/src/components/ui/select.tsx +183 -0
  43. src/frontends/adk_gemini_fullstack/frontend/src/components/ui/tabs.tsx +64 -0
  44. src/frontends/adk_gemini_fullstack/frontend/src/components/ui/textarea.tsx +18 -0
  45. src/frontends/adk_gemini_fullstack/frontend/src/global.css +154 -0
  46. src/frontends/adk_gemini_fullstack/frontend/src/main.tsx +13 -0
  47. src/frontends/adk_gemini_fullstack/frontend/src/utils.ts +7 -0
  48. src/frontends/adk_gemini_fullstack/frontend/src/vite-env.d.ts +1 -0
  49. src/frontends/adk_gemini_fullstack/frontend/tsconfig.json +28 -0
  50. src/frontends/adk_gemini_fullstack/frontend/tsconfig.node.json +24 -0
  51. src/frontends/adk_gemini_fullstack/frontend/vite.config.ts +26 -0
  52. src/resources/locks/uv-adk_base-agent_engine.lock +303 -251
  53. src/resources/locks/uv-adk_base-cloud_run.lock +367 -306
  54. src/resources/locks/uv-adk_gemini_fullstack-agent_engine.lock +3217 -0
  55. src/resources/locks/uv-adk_gemini_fullstack-cloud_run.lock +3513 -0
  56. src/resources/locks/uv-agentic_rag-agent_engine.lock +621 -565
  57. src/resources/locks/uv-agentic_rag-cloud_run.lock +854 -782
  58. src/resources/locks/uv-crewai_coding_crew-agent_engine.lock +860 -723
  59. src/resources/locks/uv-crewai_coding_crew-cloud_run.lock +1139 -960
  60. src/resources/locks/uv-langgraph_base_react-agent_engine.lock +718 -587
  61. src/resources/locks/uv-langgraph_base_react-cloud_run.lock +977 -815
  62. src/resources/locks/uv-live_api-cloud_run.lock +784 -709
  63. src/frontends/streamlit_adk/frontend/side_bar.py +0 -214
  64. src/frontends/streamlit_adk/frontend/streamlit_app.py +0 -314
  65. src/frontends/streamlit_adk/frontend/style/app_markdown.py +0 -37
  66. src/frontends/streamlit_adk/frontend/utils/chat_utils.py +0 -84
  67. src/frontends/streamlit_adk/frontend/utils/local_chat_history.py +0 -110
  68. src/frontends/streamlit_adk/frontend/utils/message_editing.py +0 -61
  69. src/frontends/streamlit_adk/frontend/utils/multimodal_utils.py +0 -223
  70. src/frontends/streamlit_adk/frontend/utils/stream_handler.py +0 -311
  71. src/frontends/streamlit_adk/frontend/utils/title_summary.py +0 -129
  72. {agent_starter_pack-0.5.2.dist-info → agent_starter_pack-0.6.0.dist-info}/WHEEL +0 -0
  73. {agent_starter_pack-0.5.2.dist-info → agent_starter_pack-0.6.0.dist-info}/entry_points.txt +0 -0
  74. {agent_starter_pack-0.5.2.dist-info → agent_starter_pack-0.6.0.dist-info}/licenses/LICENSE +0 -0
  75. /src/{deployment_targets/agent_engine → base_template}/app/utils/gcs.py +0 -0
@@ -0,0 +1,321 @@
1
+ import datetime
2
+ import logging
3
+ import os
4
+ import re
5
+ from collections.abc import AsyncGenerator
6
+ from dataclasses import dataclass
7
+ from typing import Literal
8
+
9
+ import google.auth
10
+ from google.adk.agents import LlmAgent, LoopAgent, SequentialAgent
11
+ from google.adk.agents.callback_context import CallbackContext
12
+ from google.adk.planners import BuiltInPlanner
13
+ from google.adk.tools import google_search
14
+ from google.genai import types as genai_types
15
+ from pydantic import BaseModel, Field
16
+
17
+ from google.adk.tools.agent_tool import AgentTool
18
+ from google.adk.agents import BaseAgent
19
+ from google.adk.agents.invocation_context import InvocationContext
20
+ from google.adk.events import Event, EventActions
21
+
22
+
23
+ _, project_id = google.auth.default()
24
+ os.environ.setdefault("GOOGLE_CLOUD_PROJECT", project_id)
25
+ os.environ.setdefault("GOOGLE_CLOUD_LOCATION", "global")
26
+ os.environ.setdefault("GOOGLE_GENAI_USE_VERTEXAI", "True")
27
+
28
+
29
+ # --- Centralized Configuration ---
30
+ @dataclass
31
+ class ResearchConfiguration:
32
+ critic_model: str = "gemini-2.5-pro"
33
+ worker_model: str = "gemini-2.5-flash"
34
+ max_search_iterations: int = 5
35
+
36
+
37
+ config = ResearchConfiguration()
38
+
39
+
40
+ # --- Structured Output Models ---
41
+ class SearchQuery(BaseModel):
42
+ search_query: str = Field(
43
+ description="A highly specific and targeted query for web search."
44
+ )
45
+
46
+
47
+ class Feedback(BaseModel):
48
+ grade: Literal["pass", "fail"] = Field(
49
+ description="Evaluation result. 'pass' if the research is sufficient, 'fail' if it needs revision."
50
+ )
51
+ comment: str = Field(
52
+ description="Detailed explanation of the evaluation, highlighting strengths and/or weaknesses of the research."
53
+ )
54
+ follow_up_queries: list[SearchQuery] | None = Field(
55
+ default=None,
56
+ description="A list of specific, targeted follow-up search queries needed to fix research gaps. This should be null or empty if the grade is 'pass'.",
57
+ )
58
+
59
+ # --- Callbacks ---
60
+ def collect_research_sources_callback(callback_context: CallbackContext) -> None:
61
+ session = callback_context._invocation_context.session
62
+ url_to_short_id = callback_context.state.get("url_to_short_id", {})
63
+ sources = callback_context.state.get("sources", {})
64
+ id_counter = len(url_to_short_id) + 1
65
+ for event in session.events:
66
+ if not (event.grounding_metadata and event.grounding_metadata.grounding_chunks):
67
+ continue
68
+ chunks_info = {}
69
+ for idx, chunk in enumerate(event.grounding_metadata.grounding_chunks):
70
+ if not chunk.web:
71
+ continue
72
+ url = chunk.web.uri
73
+ title = (
74
+ chunk.web.title
75
+ if chunk.web.title != chunk.web.domain
76
+ else chunk.web.domain
77
+ )
78
+ if url not in url_to_short_id:
79
+ short_id = f"src-{id_counter}"
80
+ url_to_short_id[url] = short_id
81
+ sources[short_id] = {
82
+ "short_id": short_id,
83
+ "title": title,
84
+ "url": url,
85
+ "domain": chunk.web.domain,
86
+ "supported_claims": [],
87
+ }
88
+ id_counter += 1
89
+ chunks_info[idx] = url_to_short_id[url]
90
+ if event.grounding_metadata.grounding_supports:
91
+ for support in event.grounding_metadata.grounding_supports:
92
+ confidence_scores = support.confidence_scores or []
93
+ chunk_indices = support.grounding_chunk_indices or []
94
+ for i, chunk_idx in enumerate(chunk_indices):
95
+ if chunk_idx in chunks_info:
96
+ short_id = chunks_info[chunk_idx]
97
+ confidence = (
98
+ confidence_scores[i] if i < len(confidence_scores) else 0.5
99
+ )
100
+ text_segment = support.segment.text if support.segment else ""
101
+ sources[short_id]["supported_claims"].append(
102
+ {
103
+ "text_segment": text_segment,
104
+ "confidence": confidence,
105
+ }
106
+ )
107
+ callback_context.state["url_to_short_id"] = url_to_short_id
108
+ callback_context.state["sources"] = sources
109
+
110
+
111
+ def citation_replacement_callback(callback_context: CallbackContext) -> genai_types.Content:
112
+ final_report = callback_context.state.get("final_cited_report", "")
113
+ sources = callback_context.state.get("sources", {})
114
+ def tag_replacer(match: re.Match) -> str:
115
+ short_id = match.group(1)
116
+ if not (source_info := sources.get(short_id)):
117
+ logging.warning(f"Invalid citation tag found and removed: {match.group(0)}")
118
+ return ""
119
+ display_text = source_info.get("title", source_info.get("domain", short_id))
120
+ return f" [{display_text}]({source_info['url']})"
121
+ processed_report = re.sub(
122
+ r'<cite\s+source\s*=\s*["\']?\s*(src-\d+)\s*["\']?\s*/>', tag_replacer, final_report
123
+ )
124
+ processed_report = re.sub(r'\s+([.,;:])', r'\1', processed_report)
125
+ callback_context.state["final_report_with_citations"] = processed_report
126
+ return genai_types.Content(parts=[genai_types.Part(text=processed_report)])
127
+
128
+
129
+ # --- Custom Agent for Loop Control ---
130
+ class EscalationChecker(BaseAgent):
131
+ """Checks research evaluation and escalates to stop the loop if grade is 'pass'."""
132
+ def __init__(self, name: str):
133
+ super().__init__(name=name)
134
+ async def _run_async_impl(self, ctx: InvocationContext) -> AsyncGenerator[Event, None]:
135
+ evaluation_result = ctx.session.state.get("research_evaluation")
136
+ if evaluation_result and evaluation_result.get("grade") == "pass":
137
+ logging.info(f"[{self.name}] Research evaluation passed. Escalating to stop loop.")
138
+ yield Event(author=self.name, actions=EventActions(escalate=True))
139
+ else:
140
+ logging.info(f"[{self.name}] Research evaluation failed or not found. Loop will continue.")
141
+ # Yielding an event without content or actions just lets the flow continue.
142
+ yield Event(author=self.name)
143
+
144
+
145
+ # --- AGENT DEFINITIONS ---
146
+
147
+ plan_generator = LlmAgent(
148
+ model=config.worker_model,
149
+ name="plan_generator",
150
+ description="Generates a 4-5 line action-oriented research plan, using minimal search only for topic clarification.",
151
+ instruction=f"""
152
+ You are a research strategist. Your job is to create a high-level RESEARCH PLAN, not a summary.
153
+ **RULE: Your output MUST be a bulleted list of 4-5 action-oriented research goals or key questions.**
154
+ - A good goal starts with a verb like "Analyze," "Identify," "Investigate."
155
+ - A bad output is a statement of fact like "The event was in April 2024."
156
+ **TOOL USE IS STRICTLY LIMITED:**
157
+ Your goal is to create a generic, high-quality plan *without searching*.
158
+ Only use `google_search` if a topic is ambiguous or time-sensitive and you absolutely cannot create a plan without a key piece of identifying information.
159
+ You are explicitly forbidden from researching the *content* or *themes* of the topic. That is the next agent's job. Your search is only to identify the subject, not to investigate it.
160
+ Current date: {datetime.datetime.now().strftime("%Y-%m-%d")}
161
+ """,
162
+ tools=[google_search],
163
+ )
164
+
165
+
166
+ section_planner = LlmAgent(
167
+ model=config.worker_model,
168
+ name="section_planner",
169
+ description="Breaks down the research plan into a structured markdown outline of report sections.",
170
+ instruction="""
171
+ You are an expert report architect. Using the research topic and the plan from the 'research_plan' state key, design a logical structure for the final report.
172
+ Your task is to create a markdown outline with 4-6 distinct sections that cover the topic comprehensively without overlap.
173
+ You can use any markdown format you prefer, but here's a suggested structure:
174
+ # Section Name
175
+ A brief overview of what this section covers
176
+ Feel free to add subsections or bullet points if needed to better organize the content.
177
+ Make sure your outline is clear and easy to follow.
178
+ Do not include a "References" or "Sources" section in your outline. Citations will be handled in-line.
179
+ """,
180
+ output_key="report_sections",
181
+ )
182
+
183
+
184
+ section_researcher = LlmAgent(
185
+ model=config.worker_model,
186
+ name="section_researcher",
187
+ description="Performs the crucial first pass of web research.",
188
+ planner=BuiltInPlanner(
189
+ thinking_config=genai_types.ThinkingConfig(include_thoughts=True)
190
+ ),
191
+ instruction="""
192
+ You are a diligent and exhaustive researcher. Your task is to perform the initial, broad information gathering for a report.
193
+ You will be provided with a list of sections in the 'report_sections' state key.
194
+ For each section where 'research' is marked as 'true', generate a comprehensive list of 4-5 targeted search queries to cover the topic from multiple angles.
195
+ Execute all of these queries using the 'google_search' tool and synthesize the results into a detailed summary for that section.
196
+ """,
197
+ tools=[google_search],
198
+ output_key="section_research_findings",
199
+ after_agent_callback=collect_research_sources_callback,
200
+ )
201
+
202
+ research_evaluator = LlmAgent(
203
+ model=config.critic_model,
204
+ name="research_evaluator",
205
+ description="Critically evaluates research and generates follow-up queries.",
206
+ instruction=f"""
207
+ You are a meticulous quality assurance analyst evaluating the research findings in 'section_research_findings'.
208
+
209
+ **CRITICAL RULES:**
210
+ 1. Assume the given research topic is correct. Do not question or try to verify the subject itself.
211
+ 2. Your ONLY job is to assess the quality, depth, and completeness of the research provided *for that topic*.
212
+ 3. Focus on evaluating: Comprehensiveness of coverage, logical flow and organization, use of credible sources, depth of analysis, and clarity of explanations.
213
+ 4. Do NOT fact-check or question the fundamental premise or timeline of the topic.
214
+ 5. If suggesting follow-up queries, they should dive deeper into the existing topic, not question its validity.
215
+
216
+ Be very critical about the QUALITY of research. If you find significant gaps in depth or coverage, assign a grade of "fail",
217
+ write a detailed comment about what's missing, and generate 5-7 specific follow-up queries to fill those gaps.
218
+ If the research thoroughly covers the topic, grade "pass".
219
+
220
+ Current date: {datetime.datetime.now().strftime("%Y-%m-%d")}
221
+ Your response must be a single, raw JSON object validating against the 'Feedback' schema.
222
+ """,
223
+ output_schema=Feedback,
224
+ output_key="research_evaluation",
225
+ )
226
+
227
+ enhanced_search_executor = LlmAgent(
228
+ model=config.worker_model,
229
+ name="enhanced_search_executor",
230
+ description="Executes follow-up searches and integrates new findings.",
231
+ planner=BuiltInPlanner(
232
+ thinking_config=genai_types.ThinkingConfig(include_thoughts=True)
233
+ ),
234
+ instruction="""
235
+ You are a specialist researcher executing a refinement pass.
236
+ You have been activated because the previous research was graded as 'fail'.
237
+
238
+ 1. Review the 'research_evaluation' state key to understand the feedback and required fixes.
239
+ 2. Execute EVERY query listed in 'follow_up_queries' using the 'google_search' tool.
240
+ 3. Synthesize the new findings and COMBINE them with the existing information in 'section_research_findings'.
241
+ 4. Your output MUST be the new, complete, and improved set of research findings.
242
+ """,
243
+ tools=[google_search],
244
+ output_key="section_research_findings",
245
+ after_agent_callback=collect_research_sources_callback,
246
+ )
247
+
248
+ report_composer = LlmAgent(
249
+ model=config.critic_model,
250
+ name="report_composer_with_citations",
251
+ include_contents="none",
252
+ description="Transforms research data and a markdown outline into a final, cited report.",
253
+ instruction="""
254
+ Transform the provided data into a polished, professional, and meticulously cited research report.
255
+
256
+ ---
257
+ ### INPUT DATA
258
+ * Research Plan: `{research_plan}`
259
+ * Research Findings: `{section_research_findings}`
260
+ * Citation Sources: `{sources}`
261
+ * Report Structure: `{report_sections}`
262
+
263
+ ---
264
+ ### CRITICAL: Citation System
265
+ To cite a source, you MUST insert a special citation tag directly after the claim it supports.
266
+
267
+ **The only correct format is:** `<cite source="src-ID_NUMBER" />`
268
+
269
+ ---
270
+ ### Final Instructions
271
+ Generate a comprehensive report using ONLY the `<cite source="src-ID_NUMBER" />` tag system for all citations.
272
+ The final report must strictly follow the structure provided in the **Report Structure** markdown outline.
273
+ Do not include a "References" or "Sources" section; all citations must be in-line.
274
+ """,
275
+ output_key="final_cited_report",
276
+ after_agent_callback=citation_replacement_callback,
277
+ )
278
+
279
+ research_pipeline = SequentialAgent(
280
+ name="research_pipeline",
281
+ description="Executes a pre-approved research plan. It performs iterative research, evaluation, and composes a final, cited report.",
282
+ sub_agents=[
283
+ section_planner,
284
+ section_researcher,
285
+ LoopAgent(
286
+ name="iterative_refinement_loop",
287
+ max_iterations=config.max_search_iterations,
288
+ sub_agents=[
289
+ research_evaluator,
290
+ EscalationChecker(name="escalation_checker"),
291
+ enhanced_search_executor,
292
+ ],
293
+ ),
294
+ report_composer,
295
+ ],
296
+ )
297
+
298
+ interactive_planner_agent = LlmAgent(
299
+ name="interactive_planner_agent",
300
+ model=config.worker_model,
301
+ description="The primary research assistant. It collaborates with the user to create a research plan, and then executes it upon approval.",
302
+ instruction=f"""
303
+ You are a research planning assistant. Your primary function is to convert ANY user request into a research plan.
304
+
305
+ **CRITICAL RULE: Never answer a question directly or refuse a request.** Your one and only first step is to use the `plan_generator` tool to propose a research plan for the user's topic.
306
+ If the user asks a question, you MUST immediately call `plan_generator` to create a plan to answer the question.
307
+
308
+ Your workflow is:
309
+ 1. **Plan:** Use `plan_generator` to create a draft plan and present it to the user.
310
+ 2. **Refine:** Incorporate user feedback until the plan is approved.
311
+ 3. **Execute:** Once the user gives EXPLICIT approval (e.g., "looks good, run it"), you MUST delegate the task to the `research_pipeline` agent, passing the approved plan.
312
+
313
+ Current date: {datetime.datetime.now().strftime("%Y-%m-%d")}
314
+ Do not perform any research yourself. Your job is to Plan, Refine, and Delegate.
315
+ """,
316
+ sub_agents=[research_pipeline],
317
+ tools=[AgentTool(plan_generator)],
318
+ output_key="research_plan",
319
+ )
320
+
321
+ root_agent = interactive_planner_agent
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema.json",
3
+ "style": "new-york",
4
+ "rsc": false,
5
+ "tsx": true,
6
+ "tailwind": {
7
+ "config": "",
8
+ "css": "src/app.css",
9
+ "baseColor": "neutral",
10
+ "cssVariables": true,
11
+ "prefix": ""
12
+ },
13
+ "aliases": {
14
+ "components": "@/components",
15
+ "utils": "@/lib/utils",
16
+ "ui": "@/components/ui",
17
+ "lib": "@/lib",
18
+ "hooks": "@/hooks"
19
+ },
20
+ "iconLibrary": "lucide"
21
+ }
@@ -0,0 +1,28 @@
1
+ import js from '@eslint/js'
2
+ import globals from 'globals'
3
+ import reactHooks from 'eslint-plugin-react-hooks'
4
+ import reactRefresh from 'eslint-plugin-react-refresh'
5
+ import tseslint from 'typescript-eslint'
6
+
7
+ export default tseslint.config(
8
+ { ignores: ['dist'] },
9
+ {
10
+ extends: [js.configs.recommended, ...tseslint.configs.recommended],
11
+ files: ['**/*.{ts,tsx}'],
12
+ languageOptions: {
13
+ ecmaVersion: 2020,
14
+ globals: globals.browser,
15
+ },
16
+ plugins: {
17
+ 'react-hooks': reactHooks,
18
+ 'react-refresh': reactRefresh,
19
+ },
20
+ rules: {
21
+ ...reactHooks.configs.recommended.rules,
22
+ 'react-refresh/only-export-components': [
23
+ 'warn',
24
+ { allowConstantExport: true },
25
+ ],
26
+ },
27
+ },
28
+ )
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>ADK Fullstack Agent</title>
7
+ </head>
8
+ <body>
9
+ <div id="root"></div>
10
+ <script type="module" src="/src/main.tsx"></script>
11
+ </body>
12
+ </html>