The ActResult and ActGetResult classes represent the outcome of executing an act() or act_get() call. They contain metadata about the execution and, in the case of ActGetResult, the structured response from the agent.
from nova_act import NovaActwith NovaAct(starting_page="https://example.com") as nova: result = nova.act("Click the login button") print(f"Steps: {result.metadata.num_steps_executed}") print(f"Time: {result.metadata.time_worked_s}s")
from nova_act import NovaActwith NovaAct(starting_page="https://example.com") as nova: result = nova.act("Click the submit button") # Check execution details if result.metadata.num_steps_executed > 10: print("Warning: Task took many steps") print(f"Completed at: {result.metadata.end_time}")
from nova_act import NovaAct, STRING_SCHEMAwith NovaAct(starting_page="https://example.com") as nova: # Extract a string result = nova.act_get( "What is the page title?", schema=STRING_SCHEMA ) if result.matches_schema: title = result.parsed_response print(f"Page title: {title}") else: print(f"Failed to extract: {result.response}")
with NovaAct(starting_page="https://example.com/products") as nova: result = nova.act_get( "How many products are on this page?", schema={"type": "integer"} ) if result.valid_json and result.matches_schema: count = result.parsed_response print(f"Found {count} products")
with NovaAct(starting_page="https://example.com/products") as nova: result = nova.act_get( "Extract all product names", schema={ "type": "array", "items": {"type": "string"} } ) if result.matches_schema: product_names = result.parsed_response print(f"Found {len(product_names)} products:") for name in product_names: print(f" - {name}")
Use act_get() for data extraction: When you need to extract information from a page, always use act_get() with an appropriate schema. Use act() only for actions that don’t require a response.
Check schema validation: Always check result.matches_schema before using result.parsed_response to ensure data quality.
Monitor step count: Use result.metadata.num_steps_executed to identify tasks that may be too complex or need optimization.
If result.matches_schema is False, result.parsed_response may be None or may not match your expected type. Always validate before using the data.