Skip to content

Commit 2597449

Browse files
committed
fix: make agent callback logging opt-in for CLIs
1 parent e6224f7 commit 2597449

3 files changed

Lines changed: 48 additions & 12 deletions

File tree

peak_assistant/data_assistant/__main__.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ def main() -> None:
8787
action="store_true",
8888
help="Skip user feedback and automatically accept the generated data discovery report"
8989
)
90+
parser.add_argument(
91+
"--debug-agents",
92+
action="store_true",
93+
help="Enable agent debug logging to msgs.txt and results.txt"
94+
)
9095
args = parser.parse_args()
9196

9297
# Load environment variables
@@ -156,6 +161,16 @@ def main() -> None:
156161
exit(1)
157162

158163
messages: List[TextMessage] = list()
164+
debug_agents_opts = dict()
165+
166+
if args.debug_agents:
167+
debug_agents_opts = {
168+
"msg_preprocess_callback": preprocess_messages_logging,
169+
"msg_preprocess_kwargs": {"agent_id": "data-discovery"},
170+
"msg_postprocess_callback": postprocess_messages_logging,
171+
"msg_postprocess_kwargs": {"agent_id": "data-discovery"},
172+
}
173+
159174
while True:
160175
# Run the hypothesizer asynchronously
161176
data_sources = asyncio.run(
@@ -167,10 +182,7 @@ def main() -> None:
167182
local_context=local_context,
168183
verbose=args.verbose,
169184
previous_run=messages,
170-
msg_preprocess_callback=preprocess_messages_logging,
171-
msg_preprocess_kwargs={"agent_id": "data-discovery"},
172-
msg_postprocess_callback=postprocess_messages_logging,
173-
msg_postprocess_kwargs={"agent_id": "data-discovery"},
185+
**debug_agents_opts,
174186
)
175187
)
176188

peak_assistant/hypothesis_assistant/hypothesis_refiner_cli.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,11 @@ def main() -> None:
416416
help="Skip user feedback and automatically accept the refined hypothesis",
417417
default=False,
418418
)
419+
parser.add_argument(
420+
"--debug-agents",
421+
action="store_true",
422+
help="Enable agent debug logging to msgs.txt and results.txt",
423+
)
419424

420425
# Parse the arguments
421426
args = parser.parse_args()
@@ -480,6 +485,16 @@ def main() -> None:
480485

481486
messages: List[TextMessage] = list()
482487
current_hypothesis = args.hypothesis
488+
debug_agents_opts = dict()
489+
490+
if args.debug_agents:
491+
debug_agents_opts = {
492+
"msg_preprocess_callback": preprocess_messages_logging,
493+
"msg_preprocess_kwargs": {"agent_id": "hypothesis-refiner"},
494+
"msg_postprocess_callback": postprocess_messages_logging,
495+
"msg_postprocess_kwargs": {"agent_id": "hypothesis-refiner"},
496+
}
497+
483498
while True:
484499
# Run the hypothesizer asynchronously
485500
response = asyncio.run(
@@ -490,10 +505,7 @@ def main() -> None:
490505
local_data_document=local_data or "",
491506
verbose=args.verbose,
492507
previous_run=messages,
493-
msg_preprocess_callback=preprocess_messages_logging,
494-
msg_preprocess_kwargs={"agent_id": "hypothesis-refiner"},
495-
msg_postprocess_callback=postprocess_messages_logging,
496-
msg_postprocess_kwargs={"agent_id": "hypothesis-refiner"},
508+
**debug_agents_opts,
497509
)
498510
)
499511

peak_assistant/planning_assistant/__main__.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ def main() -> None:
9595
action="store_true",
9696
help="Skip user feedback and automatically accept the generated hunt plan"
9797
)
98+
parser.add_argument(
99+
"--debug-agents",
100+
action="store_true",
101+
help="Enable agent debug logging to msgs.txt and results.txt"
102+
)
98103
args = parser.parse_args()
99104

100105
# Load environment variables
@@ -177,6 +182,16 @@ def main() -> None:
177182
exit(1)
178183

179184
messages: List[TextMessage] = list()
185+
debug_agents_opts = dict()
186+
187+
if args.debug_agents:
188+
debug_agents_opts = {
189+
"msg_preprocess_callback": preprocess_messages_logging,
190+
"msg_preprocess_kwargs": {"agent_id": "hunt-planner"},
191+
"msg_postprocess_callback": postprocess_messages_logging,
192+
"msg_postprocess_kwargs": {"agent_id": "hunt-planner"},
193+
}
194+
180195
while True:
181196
# Run the hypothesizer asynchronously
182197
data_sources = asyncio.run(
@@ -189,10 +204,7 @@ def main() -> None:
189204
local_context=local_context or "",
190205
verbose=args.verbose,
191206
previous_run=messages,
192-
msg_preprocess_callback=preprocess_messages_logging,
193-
msg_preprocess_kwargs={"agent_id": "hunt-planner"},
194-
msg_postprocess_callback=postprocess_messages_logging,
195-
msg_postprocess_kwargs={"agent_id": "hunt-planner"},
207+
**debug_agents_opts,
196208
)
197209
)
198210

0 commit comments

Comments
 (0)