def retrieve_substate_for_agent(normalized_state, agent, building):
    """
    Returns a subset of the state dictionary only containing the entries that are required by the agent.
    It will also change the keys to fit to the expected key names of the agent.
    
    The state should already be normalized in order to pass it to the agent, because the names of the keys may have changed.
    """
    state_subset = {}
    for k in agent.input_parameters:
        if k in normalized_state.keys():
            state_subset[k] = normalized_state[k]
        else:
            z_prefix, _ = building.agent_device_pairing[agent.name]
            state_subset[k] = normalized_state[f"{z_prefix} {k}"]
    return state_subset