Skip to content

Commit da8bc79

Browse files
authored
Merge pull request #5832 from aden-hive/feat/google-scopes
(micro-fix): chore: updating tool tests
2 parents a2244ad + 4296193 commit da8bc79

File tree

8 files changed

+238
-99
lines changed

8 files changed

+238
-99
lines changed

examples/templates/local_business_extractor/__main__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ def cli():
3131

3232

3333
@cli.command()
34-
@click.option("--query", "-q", type=str, required=True, help="Search query (e.g. 'bakeries in San Francisco')")
34+
@click.option(
35+
"--query",
36+
"-q",
37+
type=str,
38+
required=True,
39+
help="Search query (e.g. 'bakeries in San Francisco')",
40+
)
3541
@click.option("--quiet", is_flag=True, help="Only output result JSON")
3642
@click.option("--verbose", "-v", is_flag=True, help="Show execution details")
3743
@click.option("--debug", is_flag=True, help="Show debug logging")
@@ -123,7 +129,7 @@ async def _interactive_shell(verbose=False):
123129
result = await agent.run({"user_request": query})
124130

125131
if result.success:
126-
click.echo(f"\nExtraction complete\n")
132+
click.echo("\nExtraction complete\n")
127133
else:
128134
click.echo(f"\nExtraction failed: {result.error}\n")
129135

examples/templates/local_business_extractor/agent.py

Lines changed: 76 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from framework.graph.checkpoint_config import CheckpointConfig
88
from framework.llm import LiteLLMProvider
99
from framework.runner.tool_registry import ToolRegistry
10-
from framework.runtime.agent_runtime import AgentRuntime, create_agent_runtime
10+
from framework.runtime.agent_runtime import create_agent_runtime
1111
from framework.runtime.execution_stream import EntryPointSpec
1212

1313
from .config import default_config, metadata
@@ -18,22 +18,49 @@
1818
name="Local Business Extraction",
1919
description="Find local businesses on Maps, extract contacts, and sync to Google Sheets.",
2020
success_criteria=[
21-
SuccessCriterion(id="sc-1", description="Extract business details from Maps", metric="count", target="5", weight=0.5),
22-
SuccessCriterion(id="sc-2", description="Sync data to Google Sheets", metric="success_rate", target="1.0", weight=0.5),
21+
SuccessCriterion(
22+
id="sc-1",
23+
description="Extract business details from Maps",
24+
metric="count",
25+
target="5",
26+
weight=0.5,
27+
),
28+
SuccessCriterion(
29+
id="sc-2",
30+
description="Sync data to Google Sheets",
31+
metric="success_rate",
32+
target="1.0",
33+
weight=0.5,
34+
),
2335
],
2436
constraints=[
25-
Constraint(id="c-1", description="Must verify website presence before scraping", constraint_type="hard", category="quality"),
37+
Constraint(
38+
id="c-1",
39+
description="Must verify website presence before scraping",
40+
constraint_type="hard",
41+
category="quality",
42+
),
2643
],
2744
)
2845

2946
nodes = [map_search_gcu, extract_contacts_node, sheets_sync_node]
3047

3148
edges = [
32-
EdgeSpec(id="extract-to-sheets", source="extract-contacts", target="sheets-sync",
33-
condition=EdgeCondition.ON_SUCCESS, priority=1),
49+
EdgeSpec(
50+
id="extract-to-sheets",
51+
source="extract-contacts",
52+
target="sheets-sync",
53+
condition=EdgeCondition.ON_SUCCESS,
54+
priority=1,
55+
),
3456
# Loop back for new tasks
35-
EdgeSpec(id="sheets-to-extract", source="sheets-sync", target="extract-contacts",
36-
condition=EdgeCondition.ALWAYS, priority=1),
57+
EdgeSpec(
58+
id="sheets-to-extract",
59+
source="sheets-sync",
60+
target="extract-contacts",
61+
condition=EdgeCondition.ALWAYS,
62+
priority=1,
63+
),
3764
]
3865

3966
entry_node = "extract-contacts"
@@ -43,7 +70,12 @@
4370

4471
conversation_mode = "continuous"
4572
identity_prompt = "You are a lead generation specialist focused on local businesses."
46-
loop_config = {"max_iterations": 100, "max_tool_calls_per_turn": 30, "max_history_tokens": 32000}
73+
loop_config = {
74+
"max_iterations": 100,
75+
"max_tool_calls_per_turn": 30,
76+
"max_history_tokens": 32000,
77+
}
78+
4779

4880
class LocalBusinessExtractor:
4981
def __init__(self, config=None):
@@ -79,36 +111,60 @@ def _build_graph(self):
79111
)
80112

81113
def _setup(self):
82-
self._storage_path = Path.home() / ".hive" / "agents" / "local_business_extractor"
114+
self._storage_path = (
115+
Path.home() / ".hive" / "agents" / "local_business_extractor"
116+
)
83117
self._storage_path.mkdir(parents=True, exist_ok=True)
84118
self._tool_registry = ToolRegistry()
85119
mcp_config = Path(__file__).parent / "mcp_servers.json"
86120
if mcp_config.exists():
87121
self._tool_registry.load_mcp_config(mcp_config)
88-
llm = LiteLLMProvider(model=self.config.model, api_key=self.config.api_key, api_base=self.config.api_base)
122+
llm = LiteLLMProvider(
123+
model=self.config.model,
124+
api_key=self.config.api_key,
125+
api_base=self.config.api_base,
126+
)
89127
tools = list(self._tool_registry.get_tools().values())
90128
tool_executor = self._tool_registry.get_executor()
91129
self._graph = self._build_graph()
92130
self._agent_runtime = create_agent_runtime(
93-
graph=self._graph, goal=self.goal, storage_path=self._storage_path,
94-
entry_points=[EntryPointSpec(id="default", name="Default", entry_node=self.entry_node,
95-
trigger_type="manual", isolation_level="shared")],
96-
llm=llm, tools=tools, tool_executor=tool_executor,
97-
checkpoint_config=CheckpointConfig(enabled=True, checkpoint_on_node_complete=True),
131+
graph=self._graph,
132+
goal=self.goal,
133+
storage_path=self._storage_path,
134+
entry_points=[
135+
EntryPointSpec(
136+
id="default",
137+
name="Default",
138+
entry_node=self.entry_node,
139+
trigger_type="manual",
140+
isolation_level="shared",
141+
)
142+
],
143+
llm=llm,
144+
tools=tools,
145+
tool_executor=tool_executor,
146+
checkpoint_config=CheckpointConfig(
147+
enabled=True, checkpoint_on_node_complete=True
148+
),
98149
)
99150

100151
async def start(self):
101-
if self._agent_runtime is None: self._setup()
102-
if not self._agent_runtime.is_running: await self._agent_runtime.start()
152+
if self._agent_runtime is None:
153+
self._setup()
154+
if not self._agent_runtime.is_running:
155+
await self._agent_runtime.start()
103156

104157
async def stop(self):
105-
if self._agent_runtime and self._agent_runtime.is_running: await self._agent_runtime.stop()
158+
if self._agent_runtime and self._agent_runtime.is_running:
159+
await self._agent_runtime.stop()
106160
self._agent_runtime = None
107161

108162
async def run(self, context, session_state=None):
109163
await self.start()
110164
try:
111-
result = await self._agent_runtime.trigger_and_wait("default", context, session_state=session_state)
165+
result = await self._agent_runtime.trigger_and_wait(
166+
"default", context, session_state=session_state
167+
)
112168
return result or ExecutionResult(success=False, error="Execution timeout")
113169
finally:
114170
await self.stop()

examples/templates/local_business_extractor/nodes/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,10 @@
7777
- Use google_sheets_append_values(spreadsheet_id=id, range_name="Sheet1!A:G", values=[[name, website, email, phone, address, hours, reviews]])
7878
4. set_output("spreadsheet_id", id)
7979
""",
80-
tools=["google_sheets_create_spreadsheet", "google_sheets_update_values", "google_sheets_append_values", "google_sheets_get_values"],
80+
tools=[
81+
"google_sheets_create_spreadsheet",
82+
"google_sheets_update_values",
83+
"google_sheets_append_values",
84+
"google_sheets_get_values",
85+
],
8186
)

examples/templates/twitter_news_agent/__main__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ def cli():
3131

3232

3333
@cli.command()
34-
@click.option("--handles", "-h", type=str, default=None, help="Comma-separated Twitter handles to monitor")
34+
@click.option(
35+
"--handles",
36+
"-h",
37+
type=str,
38+
default=None,
39+
help="Comma-separated Twitter handles to monitor",
40+
)
3541
@click.option("--quiet", is_flag=True, help="Only output result JSON")
3642
@click.option("--verbose", "-v", is_flag=True, help="Show execution details")
3743
@click.option("--debug", is_flag=True, help="Show debug logging")
@@ -125,7 +131,7 @@ async def _interactive_shell(verbose=False):
125131
result = await agent.run({"user_request": query})
126132

127133
if result.success:
128-
click.echo(f"\nDigest complete\n")
134+
click.echo("\nDigest complete\n")
129135
else:
130136
click.echo(f"\nDigest failed: {result.error}\n")
131137

0 commit comments

Comments
 (0)