MCPcopy Create free account
hub / github.com/Virtual-Protocol/virtuals-python / get_agent_state_fn

Function get_agent_state_fn

examples/game/test_agent.py:40–64  ·  view source on GitHub ↗

This function will get called at every step of the agent's execution to form the agent's state. It will take as input the function result from the previous step.

(function_result: FunctionResult, current_state: dict)

Source from the content-addressed store, hash-verified

38 return new_state
39
40def get_agent_state_fn(function_result: FunctionResult, current_state: dict) -> dict:
41 """
42 This function will get called at every step of the agent's execution to form the agent's state.
43 It will take as input the function result from the previous step.
44 """
45
46 # example of fixed state (function result info is not used to change state) - the first state placed here is the initial state
47 init_state = {
48 "objects": [
49 {"name": "apple", "description": "A red apple", "type": ["item", "food"]},
50 {"name": "banana", "description": "A yellow banana", "type": ["item", "food"]},
51 {"name": "orange", "description": "A juicy orange", "type": ["item", "food"]},
52 {"name": "chair", "description": "A chair", "type": ["sittable"]},
53 {"name": "table", "description": "A table", "type": ["sittable"]},
54 ]
55 }
56
57 if current_state is None:
58 # at the first step, initialise the state with just the init state
59 new_state = init_state
60 else:
61 # do something wiht the current state input and the function result info
62 new_state = init_state # this is just an example where the state is static
63
64 return new_state
65
66
67def take_object(object: str, **kwargs) -> Tuple[FunctionResultStatus, str, dict]:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected